diff --git a/lib/application/order/order_loader/order_loader_bloc.dart b/lib/application/order/order_loader/order_loader_bloc.dart new file mode 100644 index 0000000..ee3589a --- /dev/null +++ b/lib/application/order/order_loader/order_loader_bloc.dart @@ -0,0 +1,90 @@ +import 'package:dartz/dartz.dart' hide Order; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart' hide Order; + +import '../../../domain/order/order.dart'; + +part 'order_loader_event.dart'; +part 'order_loader_state.dart'; +part 'order_loader_bloc.freezed.dart'; + +@injectable +class OrderLoaderBloc extends Bloc { + final IOrderRepository _repository; + OrderLoaderBloc(this._repository) : super(OrderLoaderState.initial()) { + on(_onOrderLoaderEvent); + } + + Future _onOrderLoaderEvent( + OrderLoaderEvent event, + Emitter emit, + ) { + return event.map( + statusChanged: (e) async { + emit(state.copyWith(status: e.status)); + }, + searchChanged: (e) async { + emit(state.copyWith(search: e.search)); + }, + fetched: (e) async { + var newState = state; + + if (e.isRefresh) { + newState = state.copyWith(isFetching: true); + + emit(newState); + } + + newState = await _mapFetchedToState(state, isRefresh: e.isRefresh); + + emit(newState); + }, + ); + } + + Future _mapFetchedToState( + OrderLoaderState state, { + bool isRefresh = false, + }) async { + state = state.copyWith(isFetching: false); + + if (state.hasReachedMax && state.orders.isNotEmpty && !isRefresh) { + return state; + } + + if (isRefresh) { + state = state.copyWith( + page: 1, + failureOptionOrder: none(), + hasReachedMax: false, + orders: [], + ); + } + + final failureOrOrder = await _repository.get( + status: state.status, + page: state.page, + search: state.search, + ); + + state = failureOrOrder.fold( + (f) { + if (state.orders.isNotEmpty) { + return state.copyWith(hasReachedMax: true); + } + return state.copyWith(failureOptionOrder: optionOf(f)); + }, + (orders) { + return state.copyWith( + orders: List.from(state.orders)..addAll(orders), + failureOptionOrder: none(), + page: state.page + 1, + hasReachedMax: orders.length < 10, + ); + }, + ); + + return state; + } +} diff --git a/lib/application/order/order_loader/order_loader_bloc.freezed.dart b/lib/application/order/order_loader/order_loader_bloc.freezed.dart new file mode 100644 index 0000000..4aed4c0 --- /dev/null +++ b/lib/application/order/order_loader/order_loader_bloc.freezed.dart @@ -0,0 +1,815 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'order_loader_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', +); + +/// @nodoc +mixin _$OrderLoaderEvent { + @optionalTypeArgs + TResult when({ + required TResult Function(String status) statusChanged, + required TResult Function(String search) searchChanged, + required TResult Function(bool isRefresh) fetched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String status)? statusChanged, + TResult? Function(String search)? searchChanged, + TResult? Function(bool isRefresh)? fetched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String status)? statusChanged, + TResult Function(String search)? searchChanged, + TResult Function(bool isRefresh)? fetched, + required TResult orElse(), + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(_StatusChanged value) statusChanged, + required TResult Function(_SearchChanged value) searchChanged, + required TResult Function(_Fetched value) fetched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_StatusChanged value)? statusChanged, + TResult? Function(_SearchChanged value)? searchChanged, + TResult? Function(_Fetched value)? fetched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_StatusChanged value)? statusChanged, + TResult Function(_SearchChanged value)? searchChanged, + TResult Function(_Fetched value)? fetched, + required TResult orElse(), + }) => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderLoaderEventCopyWith<$Res> { + factory $OrderLoaderEventCopyWith( + OrderLoaderEvent value, + $Res Function(OrderLoaderEvent) then, + ) = _$OrderLoaderEventCopyWithImpl<$Res, OrderLoaderEvent>; +} + +/// @nodoc +class _$OrderLoaderEventCopyWithImpl<$Res, $Val extends OrderLoaderEvent> + implements $OrderLoaderEventCopyWith<$Res> { + _$OrderLoaderEventCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$StatusChangedImplCopyWith<$Res> { + factory _$$StatusChangedImplCopyWith( + _$StatusChangedImpl value, + $Res Function(_$StatusChangedImpl) then, + ) = __$$StatusChangedImplCopyWithImpl<$Res>; + @useResult + $Res call({String status}); +} + +/// @nodoc +class __$$StatusChangedImplCopyWithImpl<$Res> + extends _$OrderLoaderEventCopyWithImpl<$Res, _$StatusChangedImpl> + implements _$$StatusChangedImplCopyWith<$Res> { + __$$StatusChangedImplCopyWithImpl( + _$StatusChangedImpl _value, + $Res Function(_$StatusChangedImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? status = null}) { + return _then( + _$StatusChangedImpl( + null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$StatusChangedImpl implements _StatusChanged { + const _$StatusChangedImpl(this.status); + + @override + final String status; + + @override + String toString() { + return 'OrderLoaderEvent.statusChanged(status: $status)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$StatusChangedImpl && + (identical(other.status, status) || other.status == status)); + } + + @override + int get hashCode => Object.hash(runtimeType, status); + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$StatusChangedImplCopyWith<_$StatusChangedImpl> get copyWith => + __$$StatusChangedImplCopyWithImpl<_$StatusChangedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String status) statusChanged, + required TResult Function(String search) searchChanged, + required TResult Function(bool isRefresh) fetched, + }) { + return statusChanged(status); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String status)? statusChanged, + TResult? Function(String search)? searchChanged, + TResult? Function(bool isRefresh)? fetched, + }) { + return statusChanged?.call(status); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String status)? statusChanged, + TResult Function(String search)? searchChanged, + TResult Function(bool isRefresh)? fetched, + required TResult orElse(), + }) { + if (statusChanged != null) { + return statusChanged(status); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_StatusChanged value) statusChanged, + required TResult Function(_SearchChanged value) searchChanged, + required TResult Function(_Fetched value) fetched, + }) { + return statusChanged(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_StatusChanged value)? statusChanged, + TResult? Function(_SearchChanged value)? searchChanged, + TResult? Function(_Fetched value)? fetched, + }) { + return statusChanged?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_StatusChanged value)? statusChanged, + TResult Function(_SearchChanged value)? searchChanged, + TResult Function(_Fetched value)? fetched, + required TResult orElse(), + }) { + if (statusChanged != null) { + return statusChanged(this); + } + return orElse(); + } +} + +abstract class _StatusChanged implements OrderLoaderEvent { + const factory _StatusChanged(final String status) = _$StatusChangedImpl; + + String get status; + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$StatusChangedImplCopyWith<_$StatusChangedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$SearchChangedImplCopyWith<$Res> { + factory _$$SearchChangedImplCopyWith( + _$SearchChangedImpl value, + $Res Function(_$SearchChangedImpl) then, + ) = __$$SearchChangedImplCopyWithImpl<$Res>; + @useResult + $Res call({String search}); +} + +/// @nodoc +class __$$SearchChangedImplCopyWithImpl<$Res> + extends _$OrderLoaderEventCopyWithImpl<$Res, _$SearchChangedImpl> + implements _$$SearchChangedImplCopyWith<$Res> { + __$$SearchChangedImplCopyWithImpl( + _$SearchChangedImpl _value, + $Res Function(_$SearchChangedImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? search = null}) { + return _then( + _$SearchChangedImpl( + null == search + ? _value.search + : search // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$SearchChangedImpl implements _SearchChanged { + const _$SearchChangedImpl(this.search); + + @override + final String search; + + @override + String toString() { + return 'OrderLoaderEvent.searchChanged(search: $search)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SearchChangedImpl && + (identical(other.search, search) || other.search == search)); + } + + @override + int get hashCode => Object.hash(runtimeType, search); + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SearchChangedImplCopyWith<_$SearchChangedImpl> get copyWith => + __$$SearchChangedImplCopyWithImpl<_$SearchChangedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String status) statusChanged, + required TResult Function(String search) searchChanged, + required TResult Function(bool isRefresh) fetched, + }) { + return searchChanged(search); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String status)? statusChanged, + TResult? Function(String search)? searchChanged, + TResult? Function(bool isRefresh)? fetched, + }) { + return searchChanged?.call(search); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String status)? statusChanged, + TResult Function(String search)? searchChanged, + TResult Function(bool isRefresh)? fetched, + required TResult orElse(), + }) { + if (searchChanged != null) { + return searchChanged(search); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_StatusChanged value) statusChanged, + required TResult Function(_SearchChanged value) searchChanged, + required TResult Function(_Fetched value) fetched, + }) { + return searchChanged(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_StatusChanged value)? statusChanged, + TResult? Function(_SearchChanged value)? searchChanged, + TResult? Function(_Fetched value)? fetched, + }) { + return searchChanged?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_StatusChanged value)? statusChanged, + TResult Function(_SearchChanged value)? searchChanged, + TResult Function(_Fetched value)? fetched, + required TResult orElse(), + }) { + if (searchChanged != null) { + return searchChanged(this); + } + return orElse(); + } +} + +abstract class _SearchChanged implements OrderLoaderEvent { + const factory _SearchChanged(final String search) = _$SearchChangedImpl; + + String get search; + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SearchChangedImplCopyWith<_$SearchChangedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$FetchedImplCopyWith<$Res> { + factory _$$FetchedImplCopyWith( + _$FetchedImpl value, + $Res Function(_$FetchedImpl) then, + ) = __$$FetchedImplCopyWithImpl<$Res>; + @useResult + $Res call({bool isRefresh}); +} + +/// @nodoc +class __$$FetchedImplCopyWithImpl<$Res> + extends _$OrderLoaderEventCopyWithImpl<$Res, _$FetchedImpl> + implements _$$FetchedImplCopyWith<$Res> { + __$$FetchedImplCopyWithImpl( + _$FetchedImpl _value, + $Res Function(_$FetchedImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? isRefresh = null}) { + return _then( + _$FetchedImpl( + isRefresh: null == isRefresh + ? _value.isRefresh + : isRefresh // ignore: cast_nullable_to_non_nullable + as bool, + ), + ); + } +} + +/// @nodoc + +class _$FetchedImpl implements _Fetched { + const _$FetchedImpl({this.isRefresh = false}); + + @override + @JsonKey() + final bool isRefresh; + + @override + String toString() { + return 'OrderLoaderEvent.fetched(isRefresh: $isRefresh)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$FetchedImpl && + (identical(other.isRefresh, isRefresh) || + other.isRefresh == isRefresh)); + } + + @override + int get hashCode => Object.hash(runtimeType, isRefresh); + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$FetchedImplCopyWith<_$FetchedImpl> get copyWith => + __$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String status) statusChanged, + required TResult Function(String search) searchChanged, + required TResult Function(bool isRefresh) fetched, + }) { + return fetched(isRefresh); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String status)? statusChanged, + TResult? Function(String search)? searchChanged, + TResult? Function(bool isRefresh)? fetched, + }) { + return fetched?.call(isRefresh); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String status)? statusChanged, + TResult Function(String search)? searchChanged, + TResult Function(bool isRefresh)? fetched, + required TResult orElse(), + }) { + if (fetched != null) { + return fetched(isRefresh); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_StatusChanged value) statusChanged, + required TResult Function(_SearchChanged value) searchChanged, + required TResult Function(_Fetched value) fetched, + }) { + return fetched(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_StatusChanged value)? statusChanged, + TResult? Function(_SearchChanged value)? searchChanged, + TResult? Function(_Fetched value)? fetched, + }) { + return fetched?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_StatusChanged value)? statusChanged, + TResult Function(_SearchChanged value)? searchChanged, + TResult Function(_Fetched value)? fetched, + required TResult orElse(), + }) { + if (fetched != null) { + return fetched(this); + } + return orElse(); + } +} + +abstract class _Fetched implements OrderLoaderEvent { + const factory _Fetched({final bool isRefresh}) = _$FetchedImpl; + + bool get isRefresh; + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$FetchedImplCopyWith<_$FetchedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$OrderLoaderState { + List get orders => throw _privateConstructorUsedError; + Option get failureOptionOrder => + throw _privateConstructorUsedError; + String? get status => throw _privateConstructorUsedError; + String? get search => throw _privateConstructorUsedError; + bool get isFetching => throw _privateConstructorUsedError; + bool get hasReachedMax => throw _privateConstructorUsedError; + int get page => throw _privateConstructorUsedError; + + /// Create a copy of OrderLoaderState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $OrderLoaderStateCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderLoaderStateCopyWith<$Res> { + factory $OrderLoaderStateCopyWith( + OrderLoaderState value, + $Res Function(OrderLoaderState) then, + ) = _$OrderLoaderStateCopyWithImpl<$Res, OrderLoaderState>; + @useResult + $Res call({ + List orders, + Option failureOptionOrder, + String? status, + String? search, + bool isFetching, + bool hasReachedMax, + int page, + }); +} + +/// @nodoc +class _$OrderLoaderStateCopyWithImpl<$Res, $Val extends OrderLoaderState> + implements $OrderLoaderStateCopyWith<$Res> { + _$OrderLoaderStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OrderLoaderState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? orders = null, + Object? failureOptionOrder = null, + Object? status = freezed, + Object? search = freezed, + Object? isFetching = null, + Object? hasReachedMax = null, + Object? page = null, + }) { + return _then( + _value.copyWith( + orders: null == orders + ? _value.orders + : orders // ignore: cast_nullable_to_non_nullable + as List, + failureOptionOrder: null == failureOptionOrder + ? _value.failureOptionOrder + : failureOptionOrder // ignore: cast_nullable_to_non_nullable + as Option, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + search: freezed == search + ? _value.search + : search // ignore: cast_nullable_to_non_nullable + as String?, + isFetching: null == isFetching + ? _value.isFetching + : isFetching // ignore: cast_nullable_to_non_nullable + as bool, + hasReachedMax: null == hasReachedMax + ? _value.hasReachedMax + : hasReachedMax // ignore: cast_nullable_to_non_nullable + as bool, + page: null == page + ? _value.page + : page // ignore: cast_nullable_to_non_nullable + as int, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$OrderLoaderStateImplCopyWith<$Res> + implements $OrderLoaderStateCopyWith<$Res> { + factory _$$OrderLoaderStateImplCopyWith( + _$OrderLoaderStateImpl value, + $Res Function(_$OrderLoaderStateImpl) then, + ) = __$$OrderLoaderStateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + List orders, + Option failureOptionOrder, + String? status, + String? search, + bool isFetching, + bool hasReachedMax, + int page, + }); +} + +/// @nodoc +class __$$OrderLoaderStateImplCopyWithImpl<$Res> + extends _$OrderLoaderStateCopyWithImpl<$Res, _$OrderLoaderStateImpl> + implements _$$OrderLoaderStateImplCopyWith<$Res> { + __$$OrderLoaderStateImplCopyWithImpl( + _$OrderLoaderStateImpl _value, + $Res Function(_$OrderLoaderStateImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderLoaderState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? orders = null, + Object? failureOptionOrder = null, + Object? status = freezed, + Object? search = freezed, + Object? isFetching = null, + Object? hasReachedMax = null, + Object? page = null, + }) { + return _then( + _$OrderLoaderStateImpl( + orders: null == orders + ? _value._orders + : orders // ignore: cast_nullable_to_non_nullable + as List, + failureOptionOrder: null == failureOptionOrder + ? _value.failureOptionOrder + : failureOptionOrder // ignore: cast_nullable_to_non_nullable + as Option, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + search: freezed == search + ? _value.search + : search // ignore: cast_nullable_to_non_nullable + as String?, + isFetching: null == isFetching + ? _value.isFetching + : isFetching // ignore: cast_nullable_to_non_nullable + as bool, + hasReachedMax: null == hasReachedMax + ? _value.hasReachedMax + : hasReachedMax // ignore: cast_nullable_to_non_nullable + as bool, + page: null == page + ? _value.page + : page // ignore: cast_nullable_to_non_nullable + as int, + ), + ); + } +} + +/// @nodoc + +class _$OrderLoaderStateImpl implements _OrderLoaderState { + const _$OrderLoaderStateImpl({ + required final List orders, + required this.failureOptionOrder, + this.status, + this.search, + this.isFetching = false, + this.hasReachedMax = false, + this.page = 1, + }) : _orders = orders; + + final List _orders; + @override + List get orders { + if (_orders is EqualUnmodifiableListView) return _orders; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_orders); + } + + @override + final Option failureOptionOrder; + @override + final String? status; + @override + final String? search; + @override + @JsonKey() + final bool isFetching; + @override + @JsonKey() + final bool hasReachedMax; + @override + @JsonKey() + final int page; + + @override + String toString() { + return 'OrderLoaderState(orders: $orders, failureOptionOrder: $failureOptionOrder, status: $status, search: $search, isFetching: $isFetching, hasReachedMax: $hasReachedMax, page: $page)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OrderLoaderStateImpl && + const DeepCollectionEquality().equals(other._orders, _orders) && + (identical(other.failureOptionOrder, failureOptionOrder) || + other.failureOptionOrder == failureOptionOrder) && + (identical(other.status, status) || other.status == status) && + (identical(other.search, search) || other.search == search) && + (identical(other.isFetching, isFetching) || + other.isFetching == isFetching) && + (identical(other.hasReachedMax, hasReachedMax) || + other.hasReachedMax == hasReachedMax) && + (identical(other.page, page) || other.page == page)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_orders), + failureOptionOrder, + status, + search, + isFetching, + hasReachedMax, + page, + ); + + /// Create a copy of OrderLoaderState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$OrderLoaderStateImplCopyWith<_$OrderLoaderStateImpl> get copyWith => + __$$OrderLoaderStateImplCopyWithImpl<_$OrderLoaderStateImpl>( + this, + _$identity, + ); +} + +abstract class _OrderLoaderState implements OrderLoaderState { + const factory _OrderLoaderState({ + required final List orders, + required final Option failureOptionOrder, + final String? status, + final String? search, + final bool isFetching, + final bool hasReachedMax, + final int page, + }) = _$OrderLoaderStateImpl; + + @override + List get orders; + @override + Option get failureOptionOrder; + @override + String? get status; + @override + String? get search; + @override + bool get isFetching; + @override + bool get hasReachedMax; + @override + int get page; + + /// Create a copy of OrderLoaderState + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$OrderLoaderStateImplCopyWith<_$OrderLoaderStateImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/application/order/order_loader/order_loader_event.dart b/lib/application/order/order_loader/order_loader_event.dart new file mode 100644 index 0000000..6b83945 --- /dev/null +++ b/lib/application/order/order_loader/order_loader_event.dart @@ -0,0 +1,9 @@ +part of 'order_loader_bloc.dart'; + +@freezed +class OrderLoaderEvent with _$OrderLoaderEvent { + const factory OrderLoaderEvent.statusChanged(String status) = _StatusChanged; + const factory OrderLoaderEvent.searchChanged(String search) = _SearchChanged; + const factory OrderLoaderEvent.fetched({@Default(false) bool isRefresh}) = + _Fetched; +} diff --git a/lib/application/order/order_loader/order_loader_state.dart b/lib/application/order/order_loader/order_loader_state.dart new file mode 100644 index 0000000..55e072a --- /dev/null +++ b/lib/application/order/order_loader/order_loader_state.dart @@ -0,0 +1,17 @@ +part of 'order_loader_bloc.dart'; + +@freezed +class OrderLoaderState with _$OrderLoaderState { + const factory OrderLoaderState({ + required List orders, + required Option failureOptionOrder, + String? status, + String? search, + @Default(false) bool isFetching, + @Default(false) bool hasReachedMax, + @Default(1) int page, + }) = _OrderLoaderState; + + factory OrderLoaderState.initial() => + OrderLoaderState(orders: [], failureOptionOrder: none()); +} diff --git a/lib/common/url/api_path.dart b/lib/common/url/api_path.dart index 20031cf..875d092 100644 --- a/lib/common/url/api_path.dart +++ b/lib/common/url/api_path.dart @@ -24,4 +24,7 @@ class ApiPath { // Customer static const String customer = '/api/v1/customers'; + + // Order + static const String order = '/api/v1/orders'; } diff --git a/lib/domain/order/entities/order_entity.dart b/lib/domain/order/entities/order_entity.dart new file mode 100644 index 0000000..f921570 --- /dev/null +++ b/lib/domain/order/entities/order_entity.dart @@ -0,0 +1,161 @@ +part of '../order.dart'; + +@freezed +class Order with _$Order { + const factory Order({ + required String id, + required String orderNumber, + required String outletId, + required String userId, + required String tableNumber, + required String orderType, + required String status, + required int subtotal, + required int taxAmount, + required int discountAmount, + required int totalAmount, + required int totalCost, + required int remainingAmount, + required String paymentStatus, + required int refundAmount, + required bool isVoid, + required bool isRefund, + required String notes, + required Map metadata, + required String createdAt, + required String updatedAt, + required List orderItems, + required List payments, + required int totalPaid, + required int paymentCount, + required String splitType, + }) = _Order; + + factory Order.empty() => Order( + id: '', + orderNumber: '', + outletId: '', + userId: '', + tableNumber: '', + orderType: '', + status: '', + subtotal: 0, + taxAmount: 0, + discountAmount: 0, + totalAmount: 0, + totalCost: 0, + remainingAmount: 0, + paymentStatus: '', + refundAmount: 0, + isVoid: false, + isRefund: false, + notes: '', + metadata: {}, + createdAt: '', + updatedAt: '', + orderItems: [], + payments: [], + totalPaid: 0, + paymentCount: 0, + splitType: '', + ); +} + +@freezed +class OrderItem with _$OrderItem { + const factory OrderItem({ + required String id, + required String orderId, + required String productId, + required String productName, + required int quantity, + required int price, + required int subtotal, + required int discountAmount, + required int total, + required int cost, + required Map metadata, + required String createdAt, + required String updatedAt, + }) = _OrderItem; + + factory OrderItem.empty() => OrderItem( + id: '', + orderId: '', + productId: '', + productName: '', + quantity: 0, + price: 0, + subtotal: 0, + discountAmount: 0, + total: 0, + cost: 0, + metadata: {}, + createdAt: '', + updatedAt: '', + ); +} + +@freezed +class OrderPayment with _$OrderPayment { + const factory OrderPayment({ + 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 splitType, + required String splitDescription, + required int refundAmount, + required Map metadata, + required String createdAt, + required String updatedAt, + required List paymentOrderItems, + }) = _OrderPayment; + + factory OrderPayment.empty() => OrderPayment( + id: '', + orderId: '', + paymentMethodId: '', + paymentMethodName: '', + paymentMethodType: '', + amount: 0, + status: '', + splitNumber: 0, + splitTotal: 0, + splitType: '', + splitDescription: '', + refundAmount: 0, + metadata: {}, + createdAt: '', + updatedAt: '', + paymentOrderItems: [], + ); +} + +@freezed +class PaymentOrderItem with _$PaymentOrderItem { + const factory PaymentOrderItem({ + required String id, + required String orderPaymentId, + required String orderItemId, + required int amount, + required int refundAmount, + required String createdAt, + required String updatedAt, + }) = _PaymentOrderItem; + + factory PaymentOrderItem.empty() => PaymentOrderItem( + id: '', + orderPaymentId: '', + orderItemId: '', + amount: 0, + refundAmount: 0, + createdAt: '', + updatedAt: '', + ); +} diff --git a/lib/domain/order/failures/order_failure.dart b/lib/domain/order/failures/order_failure.dart new file mode 100644 index 0000000..ed26fe4 --- /dev/null +++ b/lib/domain/order/failures/order_failure.dart @@ -0,0 +1,10 @@ +part of '../order.dart'; + +@freezed +sealed class OrderFailure with _$OrderFailure { + const factory OrderFailure.serverError(ApiFailure failure) = _ServerError; + const factory OrderFailure.unexpectedError() = _UnexpectedError; + const factory OrderFailure.empty() = _Empty; + const factory OrderFailure.dynamicErrorMessage(String erroMessage) = + _DynamicErrorMessage; +} diff --git a/lib/domain/order/order.dart b/lib/domain/order/order.dart new file mode 100644 index 0000000..73e8ed4 --- /dev/null +++ b/lib/domain/order/order.dart @@ -0,0 +1,10 @@ +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +import '../../common/api/api_failure.dart'; + +part 'order.freezed.dart'; + +part 'entities/order_entity.dart'; +part 'failures/order_failure.dart'; +part 'repositories/i_order_repository.dart'; diff --git a/lib/domain/order/order.freezed.dart b/lib/domain/order/order.freezed.dart new file mode 100644 index 0000000..3c8f628 --- /dev/null +++ b/lib/domain/order/order.freezed.dart @@ -0,0 +1,2538 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'order.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', +); + +/// @nodoc +mixin _$Order { + String get id => throw _privateConstructorUsedError; + String get orderNumber => throw _privateConstructorUsedError; + String get outletId => throw _privateConstructorUsedError; + String get userId => throw _privateConstructorUsedError; + String get tableNumber => throw _privateConstructorUsedError; + String get orderType => throw _privateConstructorUsedError; + String get status => throw _privateConstructorUsedError; + int get subtotal => throw _privateConstructorUsedError; + int get taxAmount => throw _privateConstructorUsedError; + int get discountAmount => throw _privateConstructorUsedError; + int get totalAmount => throw _privateConstructorUsedError; + int get totalCost => throw _privateConstructorUsedError; + int get remainingAmount => throw _privateConstructorUsedError; + String get paymentStatus => throw _privateConstructorUsedError; + int get refundAmount => throw _privateConstructorUsedError; + bool get isVoid => throw _privateConstructorUsedError; + bool get isRefund => throw _privateConstructorUsedError; + String get notes => throw _privateConstructorUsedError; + Map get metadata => throw _privateConstructorUsedError; + String get createdAt => throw _privateConstructorUsedError; + String get updatedAt => throw _privateConstructorUsedError; + List get orderItems => throw _privateConstructorUsedError; + List get payments => throw _privateConstructorUsedError; + int get totalPaid => throw _privateConstructorUsedError; + int get paymentCount => throw _privateConstructorUsedError; + String get splitType => throw _privateConstructorUsedError; + + /// Create a copy of Order + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $OrderCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderCopyWith<$Res> { + factory $OrderCopyWith(Order value, $Res Function(Order) then) = + _$OrderCopyWithImpl<$Res, Order>; + @useResult + $Res call({ + String id, + String orderNumber, + String outletId, + String userId, + String tableNumber, + String orderType, + String status, + int subtotal, + int taxAmount, + int discountAmount, + int totalAmount, + int totalCost, + int remainingAmount, + String paymentStatus, + int refundAmount, + bool isVoid, + bool isRefund, + String notes, + Map metadata, + String createdAt, + String updatedAt, + List orderItems, + List payments, + int totalPaid, + int paymentCount, + String splitType, + }); +} + +/// @nodoc +class _$OrderCopyWithImpl<$Res, $Val extends Order> + implements $OrderCopyWith<$Res> { + _$OrderCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Order + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderNumber = null, + Object? outletId = null, + Object? userId = null, + Object? tableNumber = null, + Object? orderType = null, + Object? status = null, + Object? subtotal = null, + Object? taxAmount = null, + Object? discountAmount = null, + Object? totalAmount = null, + Object? totalCost = null, + Object? remainingAmount = null, + Object? paymentStatus = null, + Object? refundAmount = null, + Object? isVoid = null, + Object? isRefund = null, + Object? notes = null, + Object? metadata = null, + Object? createdAt = null, + Object? updatedAt = null, + Object? orderItems = null, + Object? payments = null, + Object? totalPaid = null, + Object? paymentCount = null, + Object? splitType = null, + }) { + return _then( + _value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderNumber: null == orderNumber + ? _value.orderNumber + : orderNumber // ignore: cast_nullable_to_non_nullable + as String, + outletId: null == outletId + ? _value.outletId + : outletId // ignore: cast_nullable_to_non_nullable + as String, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as String, + tableNumber: null == tableNumber + ? _value.tableNumber + : tableNumber // ignore: cast_nullable_to_non_nullable + as String, + orderType: null == orderType + ? _value.orderType + : orderType // ignore: cast_nullable_to_non_nullable + as String, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + subtotal: null == subtotal + ? _value.subtotal + : subtotal // ignore: cast_nullable_to_non_nullable + as int, + taxAmount: null == taxAmount + ? _value.taxAmount + : taxAmount // ignore: cast_nullable_to_non_nullable + as int, + discountAmount: null == discountAmount + ? _value.discountAmount + : discountAmount // ignore: cast_nullable_to_non_nullable + as int, + totalAmount: null == totalAmount + ? _value.totalAmount + : totalAmount // ignore: cast_nullable_to_non_nullable + as int, + totalCost: null == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as int, + remainingAmount: null == remainingAmount + ? _value.remainingAmount + : remainingAmount // ignore: cast_nullable_to_non_nullable + as int, + paymentStatus: null == paymentStatus + ? _value.paymentStatus + : paymentStatus // ignore: cast_nullable_to_non_nullable + as String, + refundAmount: null == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int, + isVoid: null == isVoid + ? _value.isVoid + : isVoid // ignore: cast_nullable_to_non_nullable + as bool, + isRefund: null == isRefund + ? _value.isRefund + : isRefund // ignore: cast_nullable_to_non_nullable + as bool, + notes: null == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String, + metadata: null == metadata + ? _value.metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String, + orderItems: null == orderItems + ? _value.orderItems + : orderItems // ignore: cast_nullable_to_non_nullable + as List, + payments: null == payments + ? _value.payments + : payments // ignore: cast_nullable_to_non_nullable + as List, + totalPaid: null == totalPaid + ? _value.totalPaid + : totalPaid // ignore: cast_nullable_to_non_nullable + as int, + paymentCount: null == paymentCount + ? _value.paymentCount + : paymentCount // ignore: cast_nullable_to_non_nullable + as int, + splitType: null == splitType + ? _value.splitType + : splitType // ignore: cast_nullable_to_non_nullable + as String, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$OrderImplCopyWith<$Res> implements $OrderCopyWith<$Res> { + factory _$$OrderImplCopyWith( + _$OrderImpl value, + $Res Function(_$OrderImpl) then, + ) = __$$OrderImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String id, + String orderNumber, + String outletId, + String userId, + String tableNumber, + String orderType, + String status, + int subtotal, + int taxAmount, + int discountAmount, + int totalAmount, + int totalCost, + int remainingAmount, + String paymentStatus, + int refundAmount, + bool isVoid, + bool isRefund, + String notes, + Map metadata, + String createdAt, + String updatedAt, + List orderItems, + List payments, + int totalPaid, + int paymentCount, + String splitType, + }); +} + +/// @nodoc +class __$$OrderImplCopyWithImpl<$Res> + extends _$OrderCopyWithImpl<$Res, _$OrderImpl> + implements _$$OrderImplCopyWith<$Res> { + __$$OrderImplCopyWithImpl( + _$OrderImpl _value, + $Res Function(_$OrderImpl) _then, + ) : super(_value, _then); + + /// Create a copy of Order + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderNumber = null, + Object? outletId = null, + Object? userId = null, + Object? tableNumber = null, + Object? orderType = null, + Object? status = null, + Object? subtotal = null, + Object? taxAmount = null, + Object? discountAmount = null, + Object? totalAmount = null, + Object? totalCost = null, + Object? remainingAmount = null, + Object? paymentStatus = null, + Object? refundAmount = null, + Object? isVoid = null, + Object? isRefund = null, + Object? notes = null, + Object? metadata = null, + Object? createdAt = null, + Object? updatedAt = null, + Object? orderItems = null, + Object? payments = null, + Object? totalPaid = null, + Object? paymentCount = null, + Object? splitType = null, + }) { + return _then( + _$OrderImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderNumber: null == orderNumber + ? _value.orderNumber + : orderNumber // ignore: cast_nullable_to_non_nullable + as String, + outletId: null == outletId + ? _value.outletId + : outletId // ignore: cast_nullable_to_non_nullable + as String, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as String, + tableNumber: null == tableNumber + ? _value.tableNumber + : tableNumber // ignore: cast_nullable_to_non_nullable + as String, + orderType: null == orderType + ? _value.orderType + : orderType // ignore: cast_nullable_to_non_nullable + as String, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + subtotal: null == subtotal + ? _value.subtotal + : subtotal // ignore: cast_nullable_to_non_nullable + as int, + taxAmount: null == taxAmount + ? _value.taxAmount + : taxAmount // ignore: cast_nullable_to_non_nullable + as int, + discountAmount: null == discountAmount + ? _value.discountAmount + : discountAmount // ignore: cast_nullable_to_non_nullable + as int, + totalAmount: null == totalAmount + ? _value.totalAmount + : totalAmount // ignore: cast_nullable_to_non_nullable + as int, + totalCost: null == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as int, + remainingAmount: null == remainingAmount + ? _value.remainingAmount + : remainingAmount // ignore: cast_nullable_to_non_nullable + as int, + paymentStatus: null == paymentStatus + ? _value.paymentStatus + : paymentStatus // ignore: cast_nullable_to_non_nullable + as String, + refundAmount: null == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int, + isVoid: null == isVoid + ? _value.isVoid + : isVoid // ignore: cast_nullable_to_non_nullable + as bool, + isRefund: null == isRefund + ? _value.isRefund + : isRefund // ignore: cast_nullable_to_non_nullable + as bool, + notes: null == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String, + metadata: null == metadata + ? _value._metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String, + orderItems: null == orderItems + ? _value._orderItems + : orderItems // ignore: cast_nullable_to_non_nullable + as List, + payments: null == payments + ? _value._payments + : payments // ignore: cast_nullable_to_non_nullable + as List, + totalPaid: null == totalPaid + ? _value.totalPaid + : totalPaid // ignore: cast_nullable_to_non_nullable + as int, + paymentCount: null == paymentCount + ? _value.paymentCount + : paymentCount // ignore: cast_nullable_to_non_nullable + as int, + splitType: null == splitType + ? _value.splitType + : splitType // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$OrderImpl implements _Order { + const _$OrderImpl({ + required this.id, + required this.orderNumber, + required this.outletId, + required this.userId, + required this.tableNumber, + required this.orderType, + required this.status, + required this.subtotal, + required this.taxAmount, + required this.discountAmount, + required this.totalAmount, + required this.totalCost, + required this.remainingAmount, + required this.paymentStatus, + required this.refundAmount, + required this.isVoid, + required this.isRefund, + required this.notes, + required final Map metadata, + required this.createdAt, + required this.updatedAt, + required final List orderItems, + required final List payments, + required this.totalPaid, + required this.paymentCount, + required this.splitType, + }) : _metadata = metadata, + _orderItems = orderItems, + _payments = payments; + + @override + final String id; + @override + final String orderNumber; + @override + final String outletId; + @override + final String userId; + @override + final String tableNumber; + @override + final String orderType; + @override + final String status; + @override + final int subtotal; + @override + final int taxAmount; + @override + final int discountAmount; + @override + final int totalAmount; + @override + final int totalCost; + @override + final int remainingAmount; + @override + final String paymentStatus; + @override + final int refundAmount; + @override + final bool isVoid; + @override + final bool isRefund; + @override + final String notes; + final Map _metadata; + @override + Map get metadata { + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_metadata); + } + + @override + final String createdAt; + @override + final String updatedAt; + final List _orderItems; + @override + List get orderItems { + if (_orderItems is EqualUnmodifiableListView) return _orderItems; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_orderItems); + } + + final List _payments; + @override + List get payments { + if (_payments is EqualUnmodifiableListView) return _payments; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_payments); + } + + @override + final int totalPaid; + @override + final int paymentCount; + @override + final String splitType; + + @override + String toString() { + return 'Order(id: $id, orderNumber: $orderNumber, outletId: $outletId, userId: $userId, tableNumber: $tableNumber, orderType: $orderType, status: $status, subtotal: $subtotal, taxAmount: $taxAmount, discountAmount: $discountAmount, totalAmount: $totalAmount, totalCost: $totalCost, remainingAmount: $remainingAmount, paymentStatus: $paymentStatus, refundAmount: $refundAmount, isVoid: $isVoid, isRefund: $isRefund, notes: $notes, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt, orderItems: $orderItems, payments: $payments, totalPaid: $totalPaid, paymentCount: $paymentCount, splitType: $splitType)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OrderImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderNumber, orderNumber) || + other.orderNumber == orderNumber) && + (identical(other.outletId, outletId) || + other.outletId == outletId) && + (identical(other.userId, userId) || other.userId == userId) && + (identical(other.tableNumber, tableNumber) || + other.tableNumber == tableNumber) && + (identical(other.orderType, orderType) || + other.orderType == orderType) && + (identical(other.status, status) || other.status == status) && + (identical(other.subtotal, subtotal) || + other.subtotal == subtotal) && + (identical(other.taxAmount, taxAmount) || + other.taxAmount == taxAmount) && + (identical(other.discountAmount, discountAmount) || + other.discountAmount == discountAmount) && + (identical(other.totalAmount, totalAmount) || + other.totalAmount == totalAmount) && + (identical(other.totalCost, totalCost) || + other.totalCost == totalCost) && + (identical(other.remainingAmount, remainingAmount) || + other.remainingAmount == remainingAmount) && + (identical(other.paymentStatus, paymentStatus) || + other.paymentStatus == paymentStatus) && + (identical(other.refundAmount, refundAmount) || + other.refundAmount == refundAmount) && + (identical(other.isVoid, isVoid) || other.isVoid == isVoid) && + (identical(other.isRefund, isRefund) || + other.isRefund == isRefund) && + (identical(other.notes, notes) || other.notes == notes) && + const DeepCollectionEquality().equals(other._metadata, _metadata) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt) && + const DeepCollectionEquality().equals( + other._orderItems, + _orderItems, + ) && + const DeepCollectionEquality().equals(other._payments, _payments) && + (identical(other.totalPaid, totalPaid) || + other.totalPaid == totalPaid) && + (identical(other.paymentCount, paymentCount) || + other.paymentCount == paymentCount) && + (identical(other.splitType, splitType) || + other.splitType == splitType)); + } + + @override + int get hashCode => Object.hashAll([ + runtimeType, + id, + orderNumber, + outletId, + userId, + tableNumber, + orderType, + status, + subtotal, + taxAmount, + discountAmount, + totalAmount, + totalCost, + remainingAmount, + paymentStatus, + refundAmount, + isVoid, + isRefund, + notes, + const DeepCollectionEquality().hash(_metadata), + createdAt, + updatedAt, + const DeepCollectionEquality().hash(_orderItems), + const DeepCollectionEquality().hash(_payments), + totalPaid, + paymentCount, + splitType, + ]); + + /// Create a copy of Order + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$OrderImplCopyWith<_$OrderImpl> get copyWith => + __$$OrderImplCopyWithImpl<_$OrderImpl>(this, _$identity); +} + +abstract class _Order implements Order { + const factory _Order({ + required final String id, + required final String orderNumber, + required final String outletId, + required final String userId, + required final String tableNumber, + required final String orderType, + required final String status, + required final int subtotal, + required final int taxAmount, + required final int discountAmount, + required final int totalAmount, + required final int totalCost, + required final int remainingAmount, + required final String paymentStatus, + required final int refundAmount, + required final bool isVoid, + required final bool isRefund, + required final String notes, + required final Map metadata, + required final String createdAt, + required final String updatedAt, + required final List orderItems, + required final List payments, + required final int totalPaid, + required final int paymentCount, + required final String splitType, + }) = _$OrderImpl; + + @override + String get id; + @override + String get orderNumber; + @override + String get outletId; + @override + String get userId; + @override + String get tableNumber; + @override + String get orderType; + @override + String get status; + @override + int get subtotal; + @override + int get taxAmount; + @override + int get discountAmount; + @override + int get totalAmount; + @override + int get totalCost; + @override + int get remainingAmount; + @override + String get paymentStatus; + @override + int get refundAmount; + @override + bool get isVoid; + @override + bool get isRefund; + @override + String get notes; + @override + Map get metadata; + @override + String get createdAt; + @override + String get updatedAt; + @override + List get orderItems; + @override + List get payments; + @override + int get totalPaid; + @override + int get paymentCount; + @override + String get splitType; + + /// Create a copy of Order + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$OrderImplCopyWith<_$OrderImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$OrderItem { + String get id => throw _privateConstructorUsedError; + String get orderId => throw _privateConstructorUsedError; + String get productId => throw _privateConstructorUsedError; + String get productName => throw _privateConstructorUsedError; + int get quantity => throw _privateConstructorUsedError; + int get price => throw _privateConstructorUsedError; + int get subtotal => throw _privateConstructorUsedError; + int get discountAmount => throw _privateConstructorUsedError; + int get total => throw _privateConstructorUsedError; + int get cost => throw _privateConstructorUsedError; + Map get metadata => throw _privateConstructorUsedError; + String get createdAt => throw _privateConstructorUsedError; + String get updatedAt => throw _privateConstructorUsedError; + + /// Create a copy of OrderItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $OrderItemCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderItemCopyWith<$Res> { + factory $OrderItemCopyWith(OrderItem value, $Res Function(OrderItem) then) = + _$OrderItemCopyWithImpl<$Res, OrderItem>; + @useResult + $Res call({ + String id, + String orderId, + String productId, + String productName, + int quantity, + int price, + int subtotal, + int discountAmount, + int total, + int cost, + Map metadata, + String createdAt, + String updatedAt, + }); +} + +/// @nodoc +class _$OrderItemCopyWithImpl<$Res, $Val extends OrderItem> + implements $OrderItemCopyWith<$Res> { + _$OrderItemCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OrderItem + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderId = null, + Object? productId = null, + Object? productName = null, + Object? quantity = null, + Object? price = null, + Object? subtotal = null, + Object? discountAmount = null, + Object? total = null, + Object? cost = null, + Object? metadata = null, + Object? createdAt = null, + Object? updatedAt = null, + }) { + return _then( + _value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderId: null == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String, + productId: null == productId + ? _value.productId + : productId // ignore: cast_nullable_to_non_nullable + as String, + productName: null == productName + ? _value.productName + : productName // ignore: cast_nullable_to_non_nullable + as String, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + price: null == price + ? _value.price + : price // ignore: cast_nullable_to_non_nullable + as int, + subtotal: null == subtotal + ? _value.subtotal + : subtotal // ignore: cast_nullable_to_non_nullable + as int, + discountAmount: null == discountAmount + ? _value.discountAmount + : discountAmount // ignore: cast_nullable_to_non_nullable + as int, + total: null == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int, + cost: null == cost + ? _value.cost + : cost // ignore: cast_nullable_to_non_nullable + as int, + metadata: null == metadata + ? _value.metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$OrderItemImplCopyWith<$Res> + implements $OrderItemCopyWith<$Res> { + factory _$$OrderItemImplCopyWith( + _$OrderItemImpl value, + $Res Function(_$OrderItemImpl) then, + ) = __$$OrderItemImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String id, + String orderId, + String productId, + String productName, + int quantity, + int price, + int subtotal, + int discountAmount, + int total, + int cost, + Map metadata, + String createdAt, + String updatedAt, + }); +} + +/// @nodoc +class __$$OrderItemImplCopyWithImpl<$Res> + extends _$OrderItemCopyWithImpl<$Res, _$OrderItemImpl> + implements _$$OrderItemImplCopyWith<$Res> { + __$$OrderItemImplCopyWithImpl( + _$OrderItemImpl _value, + $Res Function(_$OrderItemImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderItem + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderId = null, + Object? productId = null, + Object? productName = null, + Object? quantity = null, + Object? price = null, + Object? subtotal = null, + Object? discountAmount = null, + Object? total = null, + Object? cost = null, + Object? metadata = null, + Object? createdAt = null, + Object? updatedAt = null, + }) { + return _then( + _$OrderItemImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderId: null == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String, + productId: null == productId + ? _value.productId + : productId // ignore: cast_nullable_to_non_nullable + as String, + productName: null == productName + ? _value.productName + : productName // ignore: cast_nullable_to_non_nullable + as String, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + price: null == price + ? _value.price + : price // ignore: cast_nullable_to_non_nullable + as int, + subtotal: null == subtotal + ? _value.subtotal + : subtotal // ignore: cast_nullable_to_non_nullable + as int, + discountAmount: null == discountAmount + ? _value.discountAmount + : discountAmount // ignore: cast_nullable_to_non_nullable + as int, + total: null == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int, + cost: null == cost + ? _value.cost + : cost // ignore: cast_nullable_to_non_nullable + as int, + metadata: null == metadata + ? _value._metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$OrderItemImpl implements _OrderItem { + const _$OrderItemImpl({ + required this.id, + required this.orderId, + required this.productId, + required this.productName, + required this.quantity, + required this.price, + required this.subtotal, + required this.discountAmount, + required this.total, + required this.cost, + required final Map metadata, + required this.createdAt, + required this.updatedAt, + }) : _metadata = metadata; + + @override + final String id; + @override + final String orderId; + @override + final String productId; + @override + final String productName; + @override + final int quantity; + @override + final int price; + @override + final int subtotal; + @override + final int discountAmount; + @override + final int total; + @override + final int cost; + final Map _metadata; + @override + Map get metadata { + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_metadata); + } + + @override + final String createdAt; + @override + final String updatedAt; + + @override + String toString() { + return 'OrderItem(id: $id, orderId: $orderId, productId: $productId, productName: $productName, quantity: $quantity, price: $price, subtotal: $subtotal, discountAmount: $discountAmount, total: $total, cost: $cost, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OrderItemImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderId, orderId) || other.orderId == orderId) && + (identical(other.productId, productId) || + other.productId == productId) && + (identical(other.productName, productName) || + other.productName == productName) && + (identical(other.quantity, quantity) || + other.quantity == quantity) && + (identical(other.price, price) || other.price == price) && + (identical(other.subtotal, subtotal) || + other.subtotal == subtotal) && + (identical(other.discountAmount, discountAmount) || + other.discountAmount == discountAmount) && + (identical(other.total, total) || other.total == total) && + (identical(other.cost, cost) || other.cost == cost) && + const DeepCollectionEquality().equals(other._metadata, _metadata) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + id, + orderId, + productId, + productName, + quantity, + price, + subtotal, + discountAmount, + total, + cost, + const DeepCollectionEquality().hash(_metadata), + createdAt, + updatedAt, + ); + + /// Create a copy of OrderItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$OrderItemImplCopyWith<_$OrderItemImpl> get copyWith => + __$$OrderItemImplCopyWithImpl<_$OrderItemImpl>(this, _$identity); +} + +abstract class _OrderItem implements OrderItem { + const factory _OrderItem({ + required final String id, + required final String orderId, + required final String productId, + required final String productName, + required final int quantity, + required final int price, + required final int subtotal, + required final int discountAmount, + required final int total, + required final int cost, + required final Map metadata, + required final String createdAt, + required final String updatedAt, + }) = _$OrderItemImpl; + + @override + String get id; + @override + String get orderId; + @override + String get productId; + @override + String get productName; + @override + int get quantity; + @override + int get price; + @override + int get subtotal; + @override + int get discountAmount; + @override + int get total; + @override + int get cost; + @override + Map get metadata; + @override + String get createdAt; + @override + String get updatedAt; + + /// Create a copy of OrderItem + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$OrderItemImplCopyWith<_$OrderItemImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$OrderPayment { + String get id => throw _privateConstructorUsedError; + String get orderId => throw _privateConstructorUsedError; + String get paymentMethodId => throw _privateConstructorUsedError; + String get paymentMethodName => throw _privateConstructorUsedError; + String get paymentMethodType => throw _privateConstructorUsedError; + int get amount => throw _privateConstructorUsedError; + String get status => throw _privateConstructorUsedError; + int get splitNumber => throw _privateConstructorUsedError; + int get splitTotal => throw _privateConstructorUsedError; + String get splitType => throw _privateConstructorUsedError; + String get splitDescription => throw _privateConstructorUsedError; + int get refundAmount => throw _privateConstructorUsedError; + Map get metadata => throw _privateConstructorUsedError; + String get createdAt => throw _privateConstructorUsedError; + String get updatedAt => throw _privateConstructorUsedError; + List get paymentOrderItems => + throw _privateConstructorUsedError; + + /// Create a copy of OrderPayment + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $OrderPaymentCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderPaymentCopyWith<$Res> { + factory $OrderPaymentCopyWith( + OrderPayment value, + $Res Function(OrderPayment) then, + ) = _$OrderPaymentCopyWithImpl<$Res, OrderPayment>; + @useResult + $Res call({ + String id, + String orderId, + String paymentMethodId, + String paymentMethodName, + String paymentMethodType, + int amount, + String status, + int splitNumber, + int splitTotal, + String splitType, + String splitDescription, + int refundAmount, + Map metadata, + String createdAt, + String updatedAt, + List paymentOrderItems, + }); +} + +/// @nodoc +class _$OrderPaymentCopyWithImpl<$Res, $Val extends OrderPayment> + implements $OrderPaymentCopyWith<$Res> { + _$OrderPaymentCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OrderPayment + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderId = null, + Object? paymentMethodId = null, + Object? paymentMethodName = null, + Object? paymentMethodType = null, + Object? amount = null, + Object? status = null, + Object? splitNumber = null, + Object? splitTotal = null, + Object? splitType = null, + Object? splitDescription = null, + Object? refundAmount = null, + Object? metadata = null, + Object? createdAt = null, + Object? updatedAt = null, + Object? paymentOrderItems = null, + }) { + return _then( + _value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderId: null == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodId: null == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodName: null == paymentMethodName + ? _value.paymentMethodName + : paymentMethodName // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodType: null == paymentMethodType + ? _value.paymentMethodType + : paymentMethodType // ignore: cast_nullable_to_non_nullable + as String, + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + splitNumber: null == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int, + splitTotal: null == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int, + splitType: null == splitType + ? _value.splitType + : splitType // ignore: cast_nullable_to_non_nullable + as String, + splitDescription: null == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String, + refundAmount: null == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int, + metadata: null == metadata + ? _value.metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String, + paymentOrderItems: null == paymentOrderItems + ? _value.paymentOrderItems + : paymentOrderItems // ignore: cast_nullable_to_non_nullable + as List, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$OrderPaymentImplCopyWith<$Res> + implements $OrderPaymentCopyWith<$Res> { + factory _$$OrderPaymentImplCopyWith( + _$OrderPaymentImpl value, + $Res Function(_$OrderPaymentImpl) then, + ) = __$$OrderPaymentImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String id, + String orderId, + String paymentMethodId, + String paymentMethodName, + String paymentMethodType, + int amount, + String status, + int splitNumber, + int splitTotal, + String splitType, + String splitDescription, + int refundAmount, + Map metadata, + String createdAt, + String updatedAt, + List paymentOrderItems, + }); +} + +/// @nodoc +class __$$OrderPaymentImplCopyWithImpl<$Res> + extends _$OrderPaymentCopyWithImpl<$Res, _$OrderPaymentImpl> + implements _$$OrderPaymentImplCopyWith<$Res> { + __$$OrderPaymentImplCopyWithImpl( + _$OrderPaymentImpl _value, + $Res Function(_$OrderPaymentImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderPayment + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderId = null, + Object? paymentMethodId = null, + Object? paymentMethodName = null, + Object? paymentMethodType = null, + Object? amount = null, + Object? status = null, + Object? splitNumber = null, + Object? splitTotal = null, + Object? splitType = null, + Object? splitDescription = null, + Object? refundAmount = null, + Object? metadata = null, + Object? createdAt = null, + Object? updatedAt = null, + Object? paymentOrderItems = null, + }) { + return _then( + _$OrderPaymentImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderId: null == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodId: null == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodName: null == paymentMethodName + ? _value.paymentMethodName + : paymentMethodName // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodType: null == paymentMethodType + ? _value.paymentMethodType + : paymentMethodType // ignore: cast_nullable_to_non_nullable + as String, + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + splitNumber: null == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int, + splitTotal: null == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int, + splitType: null == splitType + ? _value.splitType + : splitType // ignore: cast_nullable_to_non_nullable + as String, + splitDescription: null == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String, + refundAmount: null == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int, + metadata: null == metadata + ? _value._metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String, + paymentOrderItems: null == paymentOrderItems + ? _value._paymentOrderItems + : paymentOrderItems // ignore: cast_nullable_to_non_nullable + as List, + ), + ); + } +} + +/// @nodoc + +class _$OrderPaymentImpl implements _OrderPayment { + const _$OrderPaymentImpl({ + required this.id, + required this.orderId, + required this.paymentMethodId, + required this.paymentMethodName, + required this.paymentMethodType, + required this.amount, + required this.status, + required this.splitNumber, + required this.splitTotal, + required this.splitType, + required this.splitDescription, + required this.refundAmount, + required final Map metadata, + required this.createdAt, + required this.updatedAt, + required final List paymentOrderItems, + }) : _metadata = metadata, + _paymentOrderItems = paymentOrderItems; + + @override + final String id; + @override + final String orderId; + @override + final String paymentMethodId; + @override + final String paymentMethodName; + @override + final String paymentMethodType; + @override + final int amount; + @override + final String status; + @override + final int splitNumber; + @override + final int splitTotal; + @override + final String splitType; + @override + final String splitDescription; + @override + final int refundAmount; + final Map _metadata; + @override + Map get metadata { + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_metadata); + } + + @override + final String createdAt; + @override + final String updatedAt; + final List _paymentOrderItems; + @override + List get paymentOrderItems { + if (_paymentOrderItems is EqualUnmodifiableListView) + return _paymentOrderItems; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_paymentOrderItems); + } + + @override + String toString() { + return 'OrderPayment(id: $id, orderId: $orderId, paymentMethodId: $paymentMethodId, paymentMethodName: $paymentMethodName, paymentMethodType: $paymentMethodType, amount: $amount, status: $status, splitNumber: $splitNumber, splitTotal: $splitTotal, splitType: $splitType, splitDescription: $splitDescription, refundAmount: $refundAmount, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt, paymentOrderItems: $paymentOrderItems)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OrderPaymentImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderId, orderId) || other.orderId == orderId) && + (identical(other.paymentMethodId, paymentMethodId) || + other.paymentMethodId == paymentMethodId) && + (identical(other.paymentMethodName, paymentMethodName) || + other.paymentMethodName == paymentMethodName) && + (identical(other.paymentMethodType, paymentMethodType) || + other.paymentMethodType == paymentMethodType) && + (identical(other.amount, amount) || other.amount == amount) && + (identical(other.status, status) || other.status == status) && + (identical(other.splitNumber, splitNumber) || + other.splitNumber == splitNumber) && + (identical(other.splitTotal, splitTotal) || + other.splitTotal == splitTotal) && + (identical(other.splitType, splitType) || + other.splitType == splitType) && + (identical(other.splitDescription, splitDescription) || + other.splitDescription == splitDescription) && + (identical(other.refundAmount, refundAmount) || + other.refundAmount == refundAmount) && + const DeepCollectionEquality().equals(other._metadata, _metadata) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt) && + const DeepCollectionEquality().equals( + other._paymentOrderItems, + _paymentOrderItems, + )); + } + + @override + int get hashCode => Object.hash( + runtimeType, + id, + orderId, + paymentMethodId, + paymentMethodName, + paymentMethodType, + amount, + status, + splitNumber, + splitTotal, + splitType, + splitDescription, + refundAmount, + const DeepCollectionEquality().hash(_metadata), + createdAt, + updatedAt, + const DeepCollectionEquality().hash(_paymentOrderItems), + ); + + /// Create a copy of OrderPayment + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$OrderPaymentImplCopyWith<_$OrderPaymentImpl> get copyWith => + __$$OrderPaymentImplCopyWithImpl<_$OrderPaymentImpl>(this, _$identity); +} + +abstract class _OrderPayment implements OrderPayment { + const factory _OrderPayment({ + required final String id, + required final String orderId, + required final String paymentMethodId, + required final String paymentMethodName, + required final String paymentMethodType, + required final int amount, + required final String status, + required final int splitNumber, + required final int splitTotal, + required final String splitType, + required final String splitDescription, + required final int refundAmount, + required final Map metadata, + required final String createdAt, + required final String updatedAt, + required final List paymentOrderItems, + }) = _$OrderPaymentImpl; + + @override + String get id; + @override + String get orderId; + @override + String get paymentMethodId; + @override + String get paymentMethodName; + @override + String get paymentMethodType; + @override + int get amount; + @override + String get status; + @override + int get splitNumber; + @override + int get splitTotal; + @override + String get splitType; + @override + String get splitDescription; + @override + int get refundAmount; + @override + Map get metadata; + @override + String get createdAt; + @override + String get updatedAt; + @override + List get paymentOrderItems; + + /// Create a copy of OrderPayment + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$OrderPaymentImplCopyWith<_$OrderPaymentImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$PaymentOrderItem { + String get id => throw _privateConstructorUsedError; + String get orderPaymentId => throw _privateConstructorUsedError; + String get orderItemId => throw _privateConstructorUsedError; + int get amount => throw _privateConstructorUsedError; + int get refundAmount => throw _privateConstructorUsedError; + String get createdAt => throw _privateConstructorUsedError; + String get updatedAt => throw _privateConstructorUsedError; + + /// Create a copy of PaymentOrderItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PaymentOrderItemCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PaymentOrderItemCopyWith<$Res> { + factory $PaymentOrderItemCopyWith( + PaymentOrderItem value, + $Res Function(PaymentOrderItem) then, + ) = _$PaymentOrderItemCopyWithImpl<$Res, PaymentOrderItem>; + @useResult + $Res call({ + String id, + String orderPaymentId, + String orderItemId, + int amount, + int refundAmount, + String createdAt, + String updatedAt, + }); +} + +/// @nodoc +class _$PaymentOrderItemCopyWithImpl<$Res, $Val extends PaymentOrderItem> + implements $PaymentOrderItemCopyWith<$Res> { + _$PaymentOrderItemCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PaymentOrderItem + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderPaymentId = null, + Object? orderItemId = null, + Object? amount = null, + Object? refundAmount = null, + Object? createdAt = null, + Object? updatedAt = null, + }) { + return _then( + _value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderPaymentId: null == orderPaymentId + ? _value.orderPaymentId + : orderPaymentId // ignore: cast_nullable_to_non_nullable + as String, + orderItemId: null == orderItemId + ? _value.orderItemId + : orderItemId // ignore: cast_nullable_to_non_nullable + as String, + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int, + refundAmount: null == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PaymentOrderItemImplCopyWith<$Res> + implements $PaymentOrderItemCopyWith<$Res> { + factory _$$PaymentOrderItemImplCopyWith( + _$PaymentOrderItemImpl value, + $Res Function(_$PaymentOrderItemImpl) then, + ) = __$$PaymentOrderItemImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String id, + String orderPaymentId, + String orderItemId, + int amount, + int refundAmount, + String createdAt, + String updatedAt, + }); +} + +/// @nodoc +class __$$PaymentOrderItemImplCopyWithImpl<$Res> + extends _$PaymentOrderItemCopyWithImpl<$Res, _$PaymentOrderItemImpl> + implements _$$PaymentOrderItemImplCopyWith<$Res> { + __$$PaymentOrderItemImplCopyWithImpl( + _$PaymentOrderItemImpl _value, + $Res Function(_$PaymentOrderItemImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PaymentOrderItem + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderPaymentId = null, + Object? orderItemId = null, + Object? amount = null, + Object? refundAmount = null, + Object? createdAt = null, + Object? updatedAt = null, + }) { + return _then( + _$PaymentOrderItemImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderPaymentId: null == orderPaymentId + ? _value.orderPaymentId + : orderPaymentId // ignore: cast_nullable_to_non_nullable + as String, + orderItemId: null == orderItemId + ? _value.orderItemId + : orderItemId // ignore: cast_nullable_to_non_nullable + as String, + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int, + refundAmount: null == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$PaymentOrderItemImpl implements _PaymentOrderItem { + const _$PaymentOrderItemImpl({ + required this.id, + required this.orderPaymentId, + required this.orderItemId, + required this.amount, + required this.refundAmount, + required this.createdAt, + required this.updatedAt, + }); + + @override + final String id; + @override + final String orderPaymentId; + @override + final String orderItemId; + @override + final int amount; + @override + final int refundAmount; + @override + final String createdAt; + @override + final String updatedAt; + + @override + String toString() { + return 'PaymentOrderItem(id: $id, orderPaymentId: $orderPaymentId, orderItemId: $orderItemId, amount: $amount, refundAmount: $refundAmount, createdAt: $createdAt, updatedAt: $updatedAt)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentOrderItemImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderPaymentId, orderPaymentId) || + other.orderPaymentId == orderPaymentId) && + (identical(other.orderItemId, orderItemId) || + other.orderItemId == orderItemId) && + (identical(other.amount, amount) || other.amount == amount) && + (identical(other.refundAmount, refundAmount) || + other.refundAmount == refundAmount) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + id, + orderPaymentId, + orderItemId, + amount, + refundAmount, + createdAt, + updatedAt, + ); + + /// Create a copy of PaymentOrderItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PaymentOrderItemImplCopyWith<_$PaymentOrderItemImpl> get copyWith => + __$$PaymentOrderItemImplCopyWithImpl<_$PaymentOrderItemImpl>( + this, + _$identity, + ); +} + +abstract class _PaymentOrderItem implements PaymentOrderItem { + const factory _PaymentOrderItem({ + required final String id, + required final String orderPaymentId, + required final String orderItemId, + required final int amount, + required final int refundAmount, + required final String createdAt, + required final String updatedAt, + }) = _$PaymentOrderItemImpl; + + @override + String get id; + @override + String get orderPaymentId; + @override + String get orderItemId; + @override + int get amount; + @override + int get refundAmount; + @override + String get createdAt; + @override + String get updatedAt; + + /// Create a copy of PaymentOrderItem + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PaymentOrderItemImplCopyWith<_$PaymentOrderItemImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$OrderFailure { + @optionalTypeArgs + TResult when({ + required TResult Function(ApiFailure failure) serverError, + required TResult Function() unexpectedError, + required TResult Function() empty, + required TResult Function(String erroMessage) dynamicErrorMessage, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ApiFailure failure)? serverError, + TResult? Function()? unexpectedError, + TResult? Function()? empty, + TResult? Function(String erroMessage)? dynamicErrorMessage, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ApiFailure failure)? serverError, + TResult Function()? unexpectedError, + TResult Function()? empty, + TResult Function(String erroMessage)? dynamicErrorMessage, + required TResult orElse(), + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(_ServerError value) serverError, + required TResult Function(_UnexpectedError value) unexpectedError, + required TResult Function(_Empty value) empty, + required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_ServerError value)? serverError, + TResult? Function(_UnexpectedError value)? unexpectedError, + TResult? Function(_Empty value)? empty, + TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_ServerError value)? serverError, + TResult Function(_UnexpectedError value)? unexpectedError, + TResult Function(_Empty value)? empty, + TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, + required TResult orElse(), + }) => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderFailureCopyWith<$Res> { + factory $OrderFailureCopyWith( + OrderFailure value, + $Res Function(OrderFailure) then, + ) = _$OrderFailureCopyWithImpl<$Res, OrderFailure>; +} + +/// @nodoc +class _$OrderFailureCopyWithImpl<$Res, $Val extends OrderFailure> + implements $OrderFailureCopyWith<$Res> { + _$OrderFailureCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$ServerErrorImplCopyWith<$Res> { + factory _$$ServerErrorImplCopyWith( + _$ServerErrorImpl value, + $Res Function(_$ServerErrorImpl) then, + ) = __$$ServerErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({ApiFailure failure}); + + $ApiFailureCopyWith<$Res> get failure; +} + +/// @nodoc +class __$$ServerErrorImplCopyWithImpl<$Res> + extends _$OrderFailureCopyWithImpl<$Res, _$ServerErrorImpl> + implements _$$ServerErrorImplCopyWith<$Res> { + __$$ServerErrorImplCopyWithImpl( + _$ServerErrorImpl _value, + $Res Function(_$ServerErrorImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? failure = null}) { + return _then( + _$ServerErrorImpl( + null == failure + ? _value.failure + : failure // ignore: cast_nullable_to_non_nullable + as ApiFailure, + ), + ); + } + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ApiFailureCopyWith<$Res> get failure { + return $ApiFailureCopyWith<$Res>(_value.failure, (value) { + return _then(_value.copyWith(failure: value)); + }); + } +} + +/// @nodoc + +class _$ServerErrorImpl implements _ServerError { + const _$ServerErrorImpl(this.failure); + + @override + final ApiFailure failure; + + @override + String toString() { + return 'OrderFailure.serverError(failure: $failure)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ServerErrorImpl && + (identical(other.failure, failure) || other.failure == failure)); + } + + @override + int get hashCode => Object.hash(runtimeType, failure); + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith => + __$$ServerErrorImplCopyWithImpl<_$ServerErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(ApiFailure failure) serverError, + required TResult Function() unexpectedError, + required TResult Function() empty, + required TResult Function(String erroMessage) dynamicErrorMessage, + }) { + return serverError(failure); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ApiFailure failure)? serverError, + TResult? Function()? unexpectedError, + TResult? Function()? empty, + TResult? Function(String erroMessage)? dynamicErrorMessage, + }) { + return serverError?.call(failure); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ApiFailure failure)? serverError, + TResult Function()? unexpectedError, + TResult Function()? empty, + TResult Function(String erroMessage)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (serverError != null) { + return serverError(failure); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_ServerError value) serverError, + required TResult Function(_UnexpectedError value) unexpectedError, + required TResult Function(_Empty value) empty, + required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, + }) { + return serverError(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_ServerError value)? serverError, + TResult? Function(_UnexpectedError value)? unexpectedError, + TResult? Function(_Empty value)? empty, + TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, + }) { + return serverError?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_ServerError value)? serverError, + TResult Function(_UnexpectedError value)? unexpectedError, + TResult Function(_Empty value)? empty, + TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (serverError != null) { + return serverError(this); + } + return orElse(); + } +} + +abstract class _ServerError implements OrderFailure { + const factory _ServerError(final ApiFailure failure) = _$ServerErrorImpl; + + ApiFailure get failure; + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$UnexpectedErrorImplCopyWith<$Res> { + factory _$$UnexpectedErrorImplCopyWith( + _$UnexpectedErrorImpl value, + $Res Function(_$UnexpectedErrorImpl) then, + ) = __$$UnexpectedErrorImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$UnexpectedErrorImplCopyWithImpl<$Res> + extends _$OrderFailureCopyWithImpl<$Res, _$UnexpectedErrorImpl> + implements _$$UnexpectedErrorImplCopyWith<$Res> { + __$$UnexpectedErrorImplCopyWithImpl( + _$UnexpectedErrorImpl _value, + $Res Function(_$UnexpectedErrorImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$UnexpectedErrorImpl implements _UnexpectedError { + const _$UnexpectedErrorImpl(); + + @override + String toString() { + return 'OrderFailure.unexpectedError()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$UnexpectedErrorImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(ApiFailure failure) serverError, + required TResult Function() unexpectedError, + required TResult Function() empty, + required TResult Function(String erroMessage) dynamicErrorMessage, + }) { + return unexpectedError(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ApiFailure failure)? serverError, + TResult? Function()? unexpectedError, + TResult? Function()? empty, + TResult? Function(String erroMessage)? dynamicErrorMessage, + }) { + return unexpectedError?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ApiFailure failure)? serverError, + TResult Function()? unexpectedError, + TResult Function()? empty, + TResult Function(String erroMessage)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (unexpectedError != null) { + return unexpectedError(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_ServerError value) serverError, + required TResult Function(_UnexpectedError value) unexpectedError, + required TResult Function(_Empty value) empty, + required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, + }) { + return unexpectedError(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_ServerError value)? serverError, + TResult? Function(_UnexpectedError value)? unexpectedError, + TResult? Function(_Empty value)? empty, + TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, + }) { + return unexpectedError?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_ServerError value)? serverError, + TResult Function(_UnexpectedError value)? unexpectedError, + TResult Function(_Empty value)? empty, + TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (unexpectedError != null) { + return unexpectedError(this); + } + return orElse(); + } +} + +abstract class _UnexpectedError implements OrderFailure { + const factory _UnexpectedError() = _$UnexpectedErrorImpl; +} + +/// @nodoc +abstract class _$$EmptyImplCopyWith<$Res> { + factory _$$EmptyImplCopyWith( + _$EmptyImpl value, + $Res Function(_$EmptyImpl) then, + ) = __$$EmptyImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$EmptyImplCopyWithImpl<$Res> + extends _$OrderFailureCopyWithImpl<$Res, _$EmptyImpl> + implements _$$EmptyImplCopyWith<$Res> { + __$$EmptyImplCopyWithImpl( + _$EmptyImpl _value, + $Res Function(_$EmptyImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$EmptyImpl implements _Empty { + const _$EmptyImpl(); + + @override + String toString() { + return 'OrderFailure.empty()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$EmptyImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(ApiFailure failure) serverError, + required TResult Function() unexpectedError, + required TResult Function() empty, + required TResult Function(String erroMessage) dynamicErrorMessage, + }) { + return empty(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ApiFailure failure)? serverError, + TResult? Function()? unexpectedError, + TResult? Function()? empty, + TResult? Function(String erroMessage)? dynamicErrorMessage, + }) { + return empty?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ApiFailure failure)? serverError, + TResult Function()? unexpectedError, + TResult Function()? empty, + TResult Function(String erroMessage)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (empty != null) { + return empty(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_ServerError value) serverError, + required TResult Function(_UnexpectedError value) unexpectedError, + required TResult Function(_Empty value) empty, + required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, + }) { + return empty(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_ServerError value)? serverError, + TResult? Function(_UnexpectedError value)? unexpectedError, + TResult? Function(_Empty value)? empty, + TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, + }) { + return empty?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_ServerError value)? serverError, + TResult Function(_UnexpectedError value)? unexpectedError, + TResult Function(_Empty value)? empty, + TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (empty != null) { + return empty(this); + } + return orElse(); + } +} + +abstract class _Empty implements OrderFailure { + const factory _Empty() = _$EmptyImpl; +} + +/// @nodoc +abstract class _$$DynamicErrorMessageImplCopyWith<$Res> { + factory _$$DynamicErrorMessageImplCopyWith( + _$DynamicErrorMessageImpl value, + $Res Function(_$DynamicErrorMessageImpl) then, + ) = __$$DynamicErrorMessageImplCopyWithImpl<$Res>; + @useResult + $Res call({String erroMessage}); +} + +/// @nodoc +class __$$DynamicErrorMessageImplCopyWithImpl<$Res> + extends _$OrderFailureCopyWithImpl<$Res, _$DynamicErrorMessageImpl> + implements _$$DynamicErrorMessageImplCopyWith<$Res> { + __$$DynamicErrorMessageImplCopyWithImpl( + _$DynamicErrorMessageImpl _value, + $Res Function(_$DynamicErrorMessageImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? erroMessage = null}) { + return _then( + _$DynamicErrorMessageImpl( + null == erroMessage + ? _value.erroMessage + : erroMessage // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$DynamicErrorMessageImpl implements _DynamicErrorMessage { + const _$DynamicErrorMessageImpl(this.erroMessage); + + @override + final String erroMessage; + + @override + String toString() { + return 'OrderFailure.dynamicErrorMessage(erroMessage: $erroMessage)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DynamicErrorMessageImpl && + (identical(other.erroMessage, erroMessage) || + other.erroMessage == erroMessage)); + } + + @override + int get hashCode => Object.hash(runtimeType, erroMessage); + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DynamicErrorMessageImplCopyWith<_$DynamicErrorMessageImpl> get copyWith => + __$$DynamicErrorMessageImplCopyWithImpl<_$DynamicErrorMessageImpl>( + this, + _$identity, + ); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(ApiFailure failure) serverError, + required TResult Function() unexpectedError, + required TResult Function() empty, + required TResult Function(String erroMessage) dynamicErrorMessage, + }) { + return dynamicErrorMessage(erroMessage); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ApiFailure failure)? serverError, + TResult? Function()? unexpectedError, + TResult? Function()? empty, + TResult? Function(String erroMessage)? dynamicErrorMessage, + }) { + return dynamicErrorMessage?.call(erroMessage); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ApiFailure failure)? serverError, + TResult Function()? unexpectedError, + TResult Function()? empty, + TResult Function(String erroMessage)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (dynamicErrorMessage != null) { + return dynamicErrorMessage(erroMessage); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_ServerError value) serverError, + required TResult Function(_UnexpectedError value) unexpectedError, + required TResult Function(_Empty value) empty, + required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, + }) { + return dynamicErrorMessage(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_ServerError value)? serverError, + TResult? Function(_UnexpectedError value)? unexpectedError, + TResult? Function(_Empty value)? empty, + TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, + }) { + return dynamicErrorMessage?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_ServerError value)? serverError, + TResult Function(_UnexpectedError value)? unexpectedError, + TResult Function(_Empty value)? empty, + TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (dynamicErrorMessage != null) { + return dynamicErrorMessage(this); + } + return orElse(); + } +} + +abstract class _DynamicErrorMessage implements OrderFailure { + const factory _DynamicErrorMessage(final String erroMessage) = + _$DynamicErrorMessageImpl; + + String get erroMessage; + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DynamicErrorMessageImplCopyWith<_$DynamicErrorMessageImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/domain/order/repositories/i_order_repository.dart b/lib/domain/order/repositories/i_order_repository.dart new file mode 100644 index 0000000..f36b198 --- /dev/null +++ b/lib/domain/order/repositories/i_order_repository.dart @@ -0,0 +1,10 @@ +part of '../order.dart'; + +abstract class IOrderRepository { + Future>> get({ + int page = 1, + int limit = 10, + String? status, + String? search, + }); +} diff --git a/lib/infrastructure/order/datasource/remote_data_provider.dart b/lib/infrastructure/order/datasource/remote_data_provider.dart new file mode 100644 index 0000000..bd787c7 --- /dev/null +++ b/lib/infrastructure/order/datasource/remote_data_provider.dart @@ -0,0 +1,57 @@ +import 'dart:developer'; + +import 'package:data_channel/data_channel.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../common/api/api_client.dart'; +import '../../../common/api/api_failure.dart'; +import '../../../common/function/app_function.dart'; +import '../../../common/url/api_path.dart'; +import '../../../domain/order/order.dart'; +import '../order_dtos.dart'; + +@injectable +class OrderRemoteDataProvider { + final ApiClient _apiClient; + final String _logName = 'OrderRemoteDataProvider'; + + OrderRemoteDataProvider(this._apiClient); + + Future>> fetch({ + int page = 1, + int limit = 10, + String? status, + String? search, + }) async { + try { + Map params = {'page': page, 'limit': limit}; + + if (status != null && status.isNotEmpty) { + params['status'] = status; + } + + if (search != null && search.isNotEmpty) { + params['search'] = search; + } + + final response = await _apiClient.get( + ApiPath.order, + params: params, + headers: getAuthorizationHeader(), + ); + + if (response.data['data'] == null) { + return DC.error(OrderFailure.empty()); + } + + final dto = (response.data['data']['orders'] as List) + .map((item) => OrderDto.fromJson(item)) + .toList(); + + return DC.data(dto); + } on ApiFailure catch (e, s) { + log('fetchOrderError', name: _logName, error: e, stackTrace: s); + return DC.error(OrderFailure.serverError(e)); + } + } +} diff --git a/lib/infrastructure/order/dto/order_dto.dart b/lib/infrastructure/order/dto/order_dto.dart new file mode 100644 index 0000000..56d5818 --- /dev/null +++ b/lib/infrastructure/order/dto/order_dto.dart @@ -0,0 +1,183 @@ +part of '../order_dtos.dart'; + +@freezed +class OrderDto with _$OrderDto { + const OrderDto._(); + + const factory OrderDto({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'order_number') String? orderNumber, + @JsonKey(name: 'outlet_id') String? outletId, + @JsonKey(name: 'user_id') String? userId, + @JsonKey(name: 'table_number') String? tableNumber, + @JsonKey(name: 'order_type') String? orderType, + @JsonKey(name: 'status') String? status, + @JsonKey(name: 'subtotal') int? subtotal, + @JsonKey(name: 'tax_amount') int? taxAmount, + @JsonKey(name: 'discount_amount') int? discountAmount, + @JsonKey(name: 'total_amount') int? totalAmount, + @JsonKey(name: 'total_cost') int? totalCost, + @JsonKey(name: 'remaining_amount') int? remainingAmount, + @JsonKey(name: 'payment_status') String? paymentStatus, + @JsonKey(name: 'refund_amount') int? refundAmount, + @JsonKey(name: 'is_void') bool? isVoid, + @JsonKey(name: 'is_refund') bool? isRefund, + @JsonKey(name: 'notes') String? notes, + @JsonKey(name: 'metadata') Map? metadata, + @JsonKey(name: 'created_at') String? createdAt, + @JsonKey(name: 'updated_at') String? updatedAt, + @JsonKey(name: 'order_items') List? orderItems, + @JsonKey(name: 'payments') List? payments, + @JsonKey(name: 'total_paid') int? totalPaid, + @JsonKey(name: 'payment_count') int? paymentCount, + @JsonKey(name: 'split_type') String? splitType, + }) = _OrderDto; + + factory OrderDto.fromJson(Map json) => + _$OrderDtoFromJson(json); + + Order toDomain() => Order( + id: id ?? '', + orderNumber: orderNumber ?? '', + outletId: outletId ?? '', + userId: userId ?? '', + tableNumber: tableNumber ?? '', + orderType: orderType ?? '', + status: status ?? '', + subtotal: subtotal ?? 0, + taxAmount: taxAmount ?? 0, + discountAmount: discountAmount ?? 0, + totalAmount: totalAmount ?? 0, + totalCost: totalCost ?? 0, + remainingAmount: remainingAmount ?? 0, + paymentStatus: paymentStatus ?? '', + refundAmount: refundAmount ?? 0, + isVoid: isVoid ?? false, + isRefund: isRefund ?? false, + notes: notes ?? '', + metadata: metadata ?? {}, + createdAt: createdAt ?? '', + updatedAt: updatedAt ?? '', + orderItems: orderItems?.map((e) => e.toDomain()).toList() ?? [], + payments: payments?.map((e) => e.toDomain()).toList() ?? [], + totalPaid: totalPaid ?? 0, + paymentCount: paymentCount ?? 0, + splitType: splitType ?? '', + ); +} + +@freezed +class OrderItemDto with _$OrderItemDto { + const OrderItemDto._(); + + const factory OrderItemDto({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'order_id') String? orderId, + @JsonKey(name: 'product_id') String? productId, + @JsonKey(name: 'product_name') String? productName, + @JsonKey(name: 'quantity') int? quantity, + @JsonKey(name: 'price') int? price, + @JsonKey(name: 'subtotal') int? subtotal, + @JsonKey(name: 'discount_amount') int? discountAmount, + @JsonKey(name: 'total') int? total, + @JsonKey(name: 'cost') int? cost, + @JsonKey(name: 'metadata') Map? metadata, + @JsonKey(name: 'created_at') String? createdAt, + @JsonKey(name: 'updated_at') String? updatedAt, + }) = _OrderItemDto; + + factory OrderItemDto.fromJson(Map json) => + _$OrderItemDtoFromJson(json); + + OrderItem toDomain() => OrderItem( + id: id ?? '', + orderId: orderId ?? '', + productId: productId ?? '', + productName: productName ?? '', + quantity: quantity ?? 0, + price: price ?? 0, + subtotal: subtotal ?? 0, + discountAmount: discountAmount ?? 0, + total: total ?? 0, + cost: cost ?? 0, + metadata: metadata ?? {}, + createdAt: createdAt ?? '', + updatedAt: updatedAt ?? '', + ); +} + +@freezed +class OrderPaymentDto with _$OrderPaymentDto { + const OrderPaymentDto._(); + + const factory OrderPaymentDto({ + @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_type') String? splitType, + @JsonKey(name: 'split_description') String? splitDescription, + @JsonKey(name: 'refund_amount') int? refundAmount, + @JsonKey(name: 'metadata') Map? metadata, + @JsonKey(name: 'created_at') String? createdAt, + @JsonKey(name: 'updated_at') String? updatedAt, + @JsonKey(name: 'payment_order_items') + List? paymentOrderItems, + }) = _OrderPaymentDto; + + factory OrderPaymentDto.fromJson(Map json) => + _$OrderPaymentDtoFromJson(json); + + OrderPayment toDomain() => OrderPayment( + id: id ?? '', + orderId: orderId ?? '', + paymentMethodId: paymentMethodId ?? '', + paymentMethodName: paymentMethodName ?? '', + paymentMethodType: paymentMethodType ?? '', + amount: amount ?? 0, + status: status ?? '', + splitNumber: splitNumber ?? 0, + splitTotal: splitTotal ?? 0, + splitType: splitType ?? '', + splitDescription: splitDescription ?? '', + refundAmount: refundAmount ?? 0, + metadata: metadata ?? {}, + createdAt: createdAt ?? '', + updatedAt: updatedAt ?? '', + paymentOrderItems: + paymentOrderItems?.map((e) => e.toDomain()).toList() ?? [], + ); +} + +@freezed +class PaymentOrderItemDto with _$PaymentOrderItemDto { + const PaymentOrderItemDto._(); + + const factory PaymentOrderItemDto({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'order_payment_id') String? orderPaymentId, + @JsonKey(name: 'order_item_id') String? orderItemId, + @JsonKey(name: 'amount') int? amount, + @JsonKey(name: 'refund_amount') int? refundAmount, + @JsonKey(name: 'created_at') String? createdAt, + @JsonKey(name: 'updated_at') String? updatedAt, + }) = _PaymentOrderItemDto; + + factory PaymentOrderItemDto.fromJson(Map json) => + _$PaymentOrderItemDtoFromJson(json); + + PaymentOrderItem toDomain() => PaymentOrderItem( + id: id ?? '', + orderPaymentId: orderPaymentId ?? '', + orderItemId: orderItemId ?? '', + amount: amount ?? 0, + refundAmount: refundAmount ?? 0, + createdAt: createdAt ?? '', + updatedAt: updatedAt ?? '', + ); +} diff --git a/lib/infrastructure/order/order_dtos.dart b/lib/infrastructure/order/order_dtos.dart new file mode 100644 index 0000000..9855ed4 --- /dev/null +++ b/lib/infrastructure/order/order_dtos.dart @@ -0,0 +1,8 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +import '../../domain/order/order.dart'; + +part 'order_dtos.freezed.dart'; +part 'order_dtos.g.dart'; + +part 'dto/order_dto.dart'; diff --git a/lib/infrastructure/order/order_dtos.freezed.dart b/lib/infrastructure/order/order_dtos.freezed.dart new file mode 100644 index 0000000..7b4f88e --- /dev/null +++ b/lib/infrastructure/order/order_dtos.freezed.dart @@ -0,0 +1,2197 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'order_dtos.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', +); + +OrderDto _$OrderDtoFromJson(Map json) { + return _OrderDto.fromJson(json); +} + +/// @nodoc +mixin _$OrderDto { + @JsonKey(name: 'id') + String? get id => throw _privateConstructorUsedError; + @JsonKey(name: 'order_number') + String? get orderNumber => throw _privateConstructorUsedError; + @JsonKey(name: 'outlet_id') + String? get outletId => throw _privateConstructorUsedError; + @JsonKey(name: 'user_id') + String? get userId => throw _privateConstructorUsedError; + @JsonKey(name: 'table_number') + String? get tableNumber => throw _privateConstructorUsedError; + @JsonKey(name: 'order_type') + String? get orderType => throw _privateConstructorUsedError; + @JsonKey(name: 'status') + String? get status => throw _privateConstructorUsedError; + @JsonKey(name: 'subtotal') + int? get subtotal => throw _privateConstructorUsedError; + @JsonKey(name: 'tax_amount') + int? get taxAmount => throw _privateConstructorUsedError; + @JsonKey(name: 'discount_amount') + int? get discountAmount => throw _privateConstructorUsedError; + @JsonKey(name: 'total_amount') + int? get totalAmount => throw _privateConstructorUsedError; + @JsonKey(name: 'total_cost') + int? get totalCost => throw _privateConstructorUsedError; + @JsonKey(name: 'remaining_amount') + int? get remainingAmount => throw _privateConstructorUsedError; + @JsonKey(name: 'payment_status') + String? get paymentStatus => throw _privateConstructorUsedError; + @JsonKey(name: 'refund_amount') + int? get refundAmount => throw _privateConstructorUsedError; + @JsonKey(name: 'is_void') + bool? get isVoid => throw _privateConstructorUsedError; + @JsonKey(name: 'is_refund') + bool? get isRefund => throw _privateConstructorUsedError; + @JsonKey(name: 'notes') + String? get notes => throw _privateConstructorUsedError; + @JsonKey(name: 'metadata') + Map? get metadata => throw _privateConstructorUsedError; + @JsonKey(name: 'created_at') + String? get createdAt => throw _privateConstructorUsedError; + @JsonKey(name: 'updated_at') + String? get updatedAt => throw _privateConstructorUsedError; + @JsonKey(name: 'order_items') + List? get orderItems => throw _privateConstructorUsedError; + @JsonKey(name: 'payments') + List? get payments => throw _privateConstructorUsedError; + @JsonKey(name: 'total_paid') + int? get totalPaid => throw _privateConstructorUsedError; + @JsonKey(name: 'payment_count') + int? get paymentCount => throw _privateConstructorUsedError; + @JsonKey(name: 'split_type') + String? get splitType => throw _privateConstructorUsedError; + + /// Serializes this OrderDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of OrderDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $OrderDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderDtoCopyWith<$Res> { + factory $OrderDtoCopyWith(OrderDto value, $Res Function(OrderDto) then) = + _$OrderDtoCopyWithImpl<$Res, OrderDto>; + @useResult + $Res call({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'order_number') String? orderNumber, + @JsonKey(name: 'outlet_id') String? outletId, + @JsonKey(name: 'user_id') String? userId, + @JsonKey(name: 'table_number') String? tableNumber, + @JsonKey(name: 'order_type') String? orderType, + @JsonKey(name: 'status') String? status, + @JsonKey(name: 'subtotal') int? subtotal, + @JsonKey(name: 'tax_amount') int? taxAmount, + @JsonKey(name: 'discount_amount') int? discountAmount, + @JsonKey(name: 'total_amount') int? totalAmount, + @JsonKey(name: 'total_cost') int? totalCost, + @JsonKey(name: 'remaining_amount') int? remainingAmount, + @JsonKey(name: 'payment_status') String? paymentStatus, + @JsonKey(name: 'refund_amount') int? refundAmount, + @JsonKey(name: 'is_void') bool? isVoid, + @JsonKey(name: 'is_refund') bool? isRefund, + @JsonKey(name: 'notes') String? notes, + @JsonKey(name: 'metadata') Map? metadata, + @JsonKey(name: 'created_at') String? createdAt, + @JsonKey(name: 'updated_at') String? updatedAt, + @JsonKey(name: 'order_items') List? orderItems, + @JsonKey(name: 'payments') List? payments, + @JsonKey(name: 'total_paid') int? totalPaid, + @JsonKey(name: 'payment_count') int? paymentCount, + @JsonKey(name: 'split_type') String? splitType, + }); +} + +/// @nodoc +class _$OrderDtoCopyWithImpl<$Res, $Val extends OrderDto> + implements $OrderDtoCopyWith<$Res> { + _$OrderDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OrderDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderNumber = freezed, + Object? outletId = freezed, + Object? userId = freezed, + Object? tableNumber = freezed, + Object? orderType = freezed, + Object? status = freezed, + Object? subtotal = freezed, + Object? taxAmount = freezed, + Object? discountAmount = freezed, + Object? totalAmount = freezed, + Object? totalCost = freezed, + Object? remainingAmount = freezed, + Object? paymentStatus = freezed, + Object? refundAmount = freezed, + Object? isVoid = freezed, + Object? isRefund = freezed, + Object? notes = freezed, + Object? metadata = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + Object? orderItems = freezed, + Object? payments = freezed, + Object? totalPaid = freezed, + Object? paymentCount = freezed, + Object? splitType = freezed, + }) { + return _then( + _value.copyWith( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderNumber: freezed == orderNumber + ? _value.orderNumber + : orderNumber // ignore: cast_nullable_to_non_nullable + as String?, + outletId: freezed == outletId + ? _value.outletId + : outletId // ignore: cast_nullable_to_non_nullable + as String?, + userId: freezed == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as String?, + tableNumber: freezed == tableNumber + ? _value.tableNumber + : tableNumber // ignore: cast_nullable_to_non_nullable + as String?, + orderType: freezed == orderType + ? _value.orderType + : orderType // ignore: cast_nullable_to_non_nullable + as String?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + subtotal: freezed == subtotal + ? _value.subtotal + : subtotal // ignore: cast_nullable_to_non_nullable + as int?, + taxAmount: freezed == taxAmount + ? _value.taxAmount + : taxAmount // ignore: cast_nullable_to_non_nullable + as int?, + discountAmount: freezed == discountAmount + ? _value.discountAmount + : discountAmount // ignore: cast_nullable_to_non_nullable + as int?, + totalAmount: freezed == totalAmount + ? _value.totalAmount + : totalAmount // ignore: cast_nullable_to_non_nullable + as int?, + totalCost: freezed == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as int?, + remainingAmount: freezed == remainingAmount + ? _value.remainingAmount + : remainingAmount // ignore: cast_nullable_to_non_nullable + as int?, + paymentStatus: freezed == paymentStatus + ? _value.paymentStatus + : paymentStatus // ignore: cast_nullable_to_non_nullable + as String?, + refundAmount: freezed == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int?, + isVoid: freezed == isVoid + ? _value.isVoid + : isVoid // ignore: cast_nullable_to_non_nullable + as bool?, + isRefund: freezed == isRefund + ? _value.isRefund + : isRefund // ignore: cast_nullable_to_non_nullable + as bool?, + notes: freezed == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String?, + metadata: freezed == metadata + ? _value.metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map?, + createdAt: freezed == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String?, + updatedAt: freezed == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String?, + orderItems: freezed == orderItems + ? _value.orderItems + : orderItems // ignore: cast_nullable_to_non_nullable + as List?, + payments: freezed == payments + ? _value.payments + : payments // ignore: cast_nullable_to_non_nullable + as List?, + totalPaid: freezed == totalPaid + ? _value.totalPaid + : totalPaid // ignore: cast_nullable_to_non_nullable + as int?, + paymentCount: freezed == paymentCount + ? _value.paymentCount + : paymentCount // ignore: cast_nullable_to_non_nullable + as int?, + splitType: freezed == splitType + ? _value.splitType + : splitType // ignore: cast_nullable_to_non_nullable + as String?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$OrderDtoImplCopyWith<$Res> + implements $OrderDtoCopyWith<$Res> { + factory _$$OrderDtoImplCopyWith( + _$OrderDtoImpl value, + $Res Function(_$OrderDtoImpl) then, + ) = __$$OrderDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'order_number') String? orderNumber, + @JsonKey(name: 'outlet_id') String? outletId, + @JsonKey(name: 'user_id') String? userId, + @JsonKey(name: 'table_number') String? tableNumber, + @JsonKey(name: 'order_type') String? orderType, + @JsonKey(name: 'status') String? status, + @JsonKey(name: 'subtotal') int? subtotal, + @JsonKey(name: 'tax_amount') int? taxAmount, + @JsonKey(name: 'discount_amount') int? discountAmount, + @JsonKey(name: 'total_amount') int? totalAmount, + @JsonKey(name: 'total_cost') int? totalCost, + @JsonKey(name: 'remaining_amount') int? remainingAmount, + @JsonKey(name: 'payment_status') String? paymentStatus, + @JsonKey(name: 'refund_amount') int? refundAmount, + @JsonKey(name: 'is_void') bool? isVoid, + @JsonKey(name: 'is_refund') bool? isRefund, + @JsonKey(name: 'notes') String? notes, + @JsonKey(name: 'metadata') Map? metadata, + @JsonKey(name: 'created_at') String? createdAt, + @JsonKey(name: 'updated_at') String? updatedAt, + @JsonKey(name: 'order_items') List? orderItems, + @JsonKey(name: 'payments') List? payments, + @JsonKey(name: 'total_paid') int? totalPaid, + @JsonKey(name: 'payment_count') int? paymentCount, + @JsonKey(name: 'split_type') String? splitType, + }); +} + +/// @nodoc +class __$$OrderDtoImplCopyWithImpl<$Res> + extends _$OrderDtoCopyWithImpl<$Res, _$OrderDtoImpl> + implements _$$OrderDtoImplCopyWith<$Res> { + __$$OrderDtoImplCopyWithImpl( + _$OrderDtoImpl _value, + $Res Function(_$OrderDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderNumber = freezed, + Object? outletId = freezed, + Object? userId = freezed, + Object? tableNumber = freezed, + Object? orderType = freezed, + Object? status = freezed, + Object? subtotal = freezed, + Object? taxAmount = freezed, + Object? discountAmount = freezed, + Object? totalAmount = freezed, + Object? totalCost = freezed, + Object? remainingAmount = freezed, + Object? paymentStatus = freezed, + Object? refundAmount = freezed, + Object? isVoid = freezed, + Object? isRefund = freezed, + Object? notes = freezed, + Object? metadata = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + Object? orderItems = freezed, + Object? payments = freezed, + Object? totalPaid = freezed, + Object? paymentCount = freezed, + Object? splitType = freezed, + }) { + return _then( + _$OrderDtoImpl( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderNumber: freezed == orderNumber + ? _value.orderNumber + : orderNumber // ignore: cast_nullable_to_non_nullable + as String?, + outletId: freezed == outletId + ? _value.outletId + : outletId // ignore: cast_nullable_to_non_nullable + as String?, + userId: freezed == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as String?, + tableNumber: freezed == tableNumber + ? _value.tableNumber + : tableNumber // ignore: cast_nullable_to_non_nullable + as String?, + orderType: freezed == orderType + ? _value.orderType + : orderType // ignore: cast_nullable_to_non_nullable + as String?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + subtotal: freezed == subtotal + ? _value.subtotal + : subtotal // ignore: cast_nullable_to_non_nullable + as int?, + taxAmount: freezed == taxAmount + ? _value.taxAmount + : taxAmount // ignore: cast_nullable_to_non_nullable + as int?, + discountAmount: freezed == discountAmount + ? _value.discountAmount + : discountAmount // ignore: cast_nullable_to_non_nullable + as int?, + totalAmount: freezed == totalAmount + ? _value.totalAmount + : totalAmount // ignore: cast_nullable_to_non_nullable + as int?, + totalCost: freezed == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as int?, + remainingAmount: freezed == remainingAmount + ? _value.remainingAmount + : remainingAmount // ignore: cast_nullable_to_non_nullable + as int?, + paymentStatus: freezed == paymentStatus + ? _value.paymentStatus + : paymentStatus // ignore: cast_nullable_to_non_nullable + as String?, + refundAmount: freezed == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int?, + isVoid: freezed == isVoid + ? _value.isVoid + : isVoid // ignore: cast_nullable_to_non_nullable + as bool?, + isRefund: freezed == isRefund + ? _value.isRefund + : isRefund // ignore: cast_nullable_to_non_nullable + as bool?, + notes: freezed == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String?, + metadata: freezed == metadata + ? _value._metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map?, + createdAt: freezed == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String?, + updatedAt: freezed == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String?, + orderItems: freezed == orderItems + ? _value._orderItems + : orderItems // ignore: cast_nullable_to_non_nullable + as List?, + payments: freezed == payments + ? _value._payments + : payments // ignore: cast_nullable_to_non_nullable + as List?, + totalPaid: freezed == totalPaid + ? _value.totalPaid + : totalPaid // ignore: cast_nullable_to_non_nullable + as int?, + paymentCount: freezed == paymentCount + ? _value.paymentCount + : paymentCount // ignore: cast_nullable_to_non_nullable + as int?, + splitType: freezed == splitType + ? _value.splitType + : splitType // ignore: cast_nullable_to_non_nullable + as String?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$OrderDtoImpl extends _OrderDto { + const _$OrderDtoImpl({ + @JsonKey(name: 'id') this.id, + @JsonKey(name: 'order_number') this.orderNumber, + @JsonKey(name: 'outlet_id') this.outletId, + @JsonKey(name: 'user_id') this.userId, + @JsonKey(name: 'table_number') this.tableNumber, + @JsonKey(name: 'order_type') this.orderType, + @JsonKey(name: 'status') this.status, + @JsonKey(name: 'subtotal') this.subtotal, + @JsonKey(name: 'tax_amount') this.taxAmount, + @JsonKey(name: 'discount_amount') this.discountAmount, + @JsonKey(name: 'total_amount') this.totalAmount, + @JsonKey(name: 'total_cost') this.totalCost, + @JsonKey(name: 'remaining_amount') this.remainingAmount, + @JsonKey(name: 'payment_status') this.paymentStatus, + @JsonKey(name: 'refund_amount') this.refundAmount, + @JsonKey(name: 'is_void') this.isVoid, + @JsonKey(name: 'is_refund') this.isRefund, + @JsonKey(name: 'notes') this.notes, + @JsonKey(name: 'metadata') final Map? metadata, + @JsonKey(name: 'created_at') this.createdAt, + @JsonKey(name: 'updated_at') this.updatedAt, + @JsonKey(name: 'order_items') final List? orderItems, + @JsonKey(name: 'payments') final List? payments, + @JsonKey(name: 'total_paid') this.totalPaid, + @JsonKey(name: 'payment_count') this.paymentCount, + @JsonKey(name: 'split_type') this.splitType, + }) : _metadata = metadata, + _orderItems = orderItems, + _payments = payments, + super._(); + + factory _$OrderDtoImpl.fromJson(Map json) => + _$$OrderDtoImplFromJson(json); + + @override + @JsonKey(name: 'id') + final String? id; + @override + @JsonKey(name: 'order_number') + final String? orderNumber; + @override + @JsonKey(name: 'outlet_id') + final String? outletId; + @override + @JsonKey(name: 'user_id') + final String? userId; + @override + @JsonKey(name: 'table_number') + final String? tableNumber; + @override + @JsonKey(name: 'order_type') + final String? orderType; + @override + @JsonKey(name: 'status') + final String? status; + @override + @JsonKey(name: 'subtotal') + final int? subtotal; + @override + @JsonKey(name: 'tax_amount') + final int? taxAmount; + @override + @JsonKey(name: 'discount_amount') + final int? discountAmount; + @override + @JsonKey(name: 'total_amount') + final int? totalAmount; + @override + @JsonKey(name: 'total_cost') + final int? totalCost; + @override + @JsonKey(name: 'remaining_amount') + final int? remainingAmount; + @override + @JsonKey(name: 'payment_status') + final String? paymentStatus; + @override + @JsonKey(name: 'refund_amount') + final int? refundAmount; + @override + @JsonKey(name: 'is_void') + final bool? isVoid; + @override + @JsonKey(name: 'is_refund') + final bool? isRefund; + @override + @JsonKey(name: 'notes') + final String? notes; + final Map? _metadata; + @override + @JsonKey(name: 'metadata') + Map? get metadata { + final value = _metadata; + if (value == null) return null; + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + @override + @JsonKey(name: 'created_at') + final String? createdAt; + @override + @JsonKey(name: 'updated_at') + final String? updatedAt; + final List? _orderItems; + @override + @JsonKey(name: 'order_items') + List? get orderItems { + final value = _orderItems; + if (value == null) return null; + if (_orderItems is EqualUnmodifiableListView) return _orderItems; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + final List? _payments; + @override + @JsonKey(name: 'payments') + List? get payments { + final value = _payments; + if (value == null) return null; + if (_payments is EqualUnmodifiableListView) return _payments; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + @JsonKey(name: 'total_paid') + final int? totalPaid; + @override + @JsonKey(name: 'payment_count') + final int? paymentCount; + @override + @JsonKey(name: 'split_type') + final String? splitType; + + @override + String toString() { + return 'OrderDto(id: $id, orderNumber: $orderNumber, outletId: $outletId, userId: $userId, tableNumber: $tableNumber, orderType: $orderType, status: $status, subtotal: $subtotal, taxAmount: $taxAmount, discountAmount: $discountAmount, totalAmount: $totalAmount, totalCost: $totalCost, remainingAmount: $remainingAmount, paymentStatus: $paymentStatus, refundAmount: $refundAmount, isVoid: $isVoid, isRefund: $isRefund, notes: $notes, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt, orderItems: $orderItems, payments: $payments, totalPaid: $totalPaid, paymentCount: $paymentCount, splitType: $splitType)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OrderDtoImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderNumber, orderNumber) || + other.orderNumber == orderNumber) && + (identical(other.outletId, outletId) || + other.outletId == outletId) && + (identical(other.userId, userId) || other.userId == userId) && + (identical(other.tableNumber, tableNumber) || + other.tableNumber == tableNumber) && + (identical(other.orderType, orderType) || + other.orderType == orderType) && + (identical(other.status, status) || other.status == status) && + (identical(other.subtotal, subtotal) || + other.subtotal == subtotal) && + (identical(other.taxAmount, taxAmount) || + other.taxAmount == taxAmount) && + (identical(other.discountAmount, discountAmount) || + other.discountAmount == discountAmount) && + (identical(other.totalAmount, totalAmount) || + other.totalAmount == totalAmount) && + (identical(other.totalCost, totalCost) || + other.totalCost == totalCost) && + (identical(other.remainingAmount, remainingAmount) || + other.remainingAmount == remainingAmount) && + (identical(other.paymentStatus, paymentStatus) || + other.paymentStatus == paymentStatus) && + (identical(other.refundAmount, refundAmount) || + other.refundAmount == refundAmount) && + (identical(other.isVoid, isVoid) || other.isVoid == isVoid) && + (identical(other.isRefund, isRefund) || + other.isRefund == isRefund) && + (identical(other.notes, notes) || other.notes == notes) && + const DeepCollectionEquality().equals(other._metadata, _metadata) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt) && + const DeepCollectionEquality().equals( + other._orderItems, + _orderItems, + ) && + const DeepCollectionEquality().equals(other._payments, _payments) && + (identical(other.totalPaid, totalPaid) || + other.totalPaid == totalPaid) && + (identical(other.paymentCount, paymentCount) || + other.paymentCount == paymentCount) && + (identical(other.splitType, splitType) || + other.splitType == splitType)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hashAll([ + runtimeType, + id, + orderNumber, + outletId, + userId, + tableNumber, + orderType, + status, + subtotal, + taxAmount, + discountAmount, + totalAmount, + totalCost, + remainingAmount, + paymentStatus, + refundAmount, + isVoid, + isRefund, + notes, + const DeepCollectionEquality().hash(_metadata), + createdAt, + updatedAt, + const DeepCollectionEquality().hash(_orderItems), + const DeepCollectionEquality().hash(_payments), + totalPaid, + paymentCount, + splitType, + ]); + + /// Create a copy of OrderDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$OrderDtoImplCopyWith<_$OrderDtoImpl> get copyWith => + __$$OrderDtoImplCopyWithImpl<_$OrderDtoImpl>(this, _$identity); + + @override + Map toJson() { + return _$$OrderDtoImplToJson(this); + } +} + +abstract class _OrderDto extends OrderDto { + const factory _OrderDto({ + @JsonKey(name: 'id') final String? id, + @JsonKey(name: 'order_number') final String? orderNumber, + @JsonKey(name: 'outlet_id') final String? outletId, + @JsonKey(name: 'user_id') final String? userId, + @JsonKey(name: 'table_number') final String? tableNumber, + @JsonKey(name: 'order_type') final String? orderType, + @JsonKey(name: 'status') final String? status, + @JsonKey(name: 'subtotal') final int? subtotal, + @JsonKey(name: 'tax_amount') final int? taxAmount, + @JsonKey(name: 'discount_amount') final int? discountAmount, + @JsonKey(name: 'total_amount') final int? totalAmount, + @JsonKey(name: 'total_cost') final int? totalCost, + @JsonKey(name: 'remaining_amount') final int? remainingAmount, + @JsonKey(name: 'payment_status') final String? paymentStatus, + @JsonKey(name: 'refund_amount') final int? refundAmount, + @JsonKey(name: 'is_void') final bool? isVoid, + @JsonKey(name: 'is_refund') final bool? isRefund, + @JsonKey(name: 'notes') final String? notes, + @JsonKey(name: 'metadata') final Map? metadata, + @JsonKey(name: 'created_at') final String? createdAt, + @JsonKey(name: 'updated_at') final String? updatedAt, + @JsonKey(name: 'order_items') final List? orderItems, + @JsonKey(name: 'payments') final List? payments, + @JsonKey(name: 'total_paid') final int? totalPaid, + @JsonKey(name: 'payment_count') final int? paymentCount, + @JsonKey(name: 'split_type') final String? splitType, + }) = _$OrderDtoImpl; + const _OrderDto._() : super._(); + + factory _OrderDto.fromJson(Map json) = + _$OrderDtoImpl.fromJson; + + @override + @JsonKey(name: 'id') + String? get id; + @override + @JsonKey(name: 'order_number') + String? get orderNumber; + @override + @JsonKey(name: 'outlet_id') + String? get outletId; + @override + @JsonKey(name: 'user_id') + String? get userId; + @override + @JsonKey(name: 'table_number') + String? get tableNumber; + @override + @JsonKey(name: 'order_type') + String? get orderType; + @override + @JsonKey(name: 'status') + String? get status; + @override + @JsonKey(name: 'subtotal') + int? get subtotal; + @override + @JsonKey(name: 'tax_amount') + int? get taxAmount; + @override + @JsonKey(name: 'discount_amount') + int? get discountAmount; + @override + @JsonKey(name: 'total_amount') + int? get totalAmount; + @override + @JsonKey(name: 'total_cost') + int? get totalCost; + @override + @JsonKey(name: 'remaining_amount') + int? get remainingAmount; + @override + @JsonKey(name: 'payment_status') + String? get paymentStatus; + @override + @JsonKey(name: 'refund_amount') + int? get refundAmount; + @override + @JsonKey(name: 'is_void') + bool? get isVoid; + @override + @JsonKey(name: 'is_refund') + bool? get isRefund; + @override + @JsonKey(name: 'notes') + String? get notes; + @override + @JsonKey(name: 'metadata') + Map? get metadata; + @override + @JsonKey(name: 'created_at') + String? get createdAt; + @override + @JsonKey(name: 'updated_at') + String? get updatedAt; + @override + @JsonKey(name: 'order_items') + List? get orderItems; + @override + @JsonKey(name: 'payments') + List? get payments; + @override + @JsonKey(name: 'total_paid') + int? get totalPaid; + @override + @JsonKey(name: 'payment_count') + int? get paymentCount; + @override + @JsonKey(name: 'split_type') + String? get splitType; + + /// Create a copy of OrderDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$OrderDtoImplCopyWith<_$OrderDtoImpl> get copyWith => + throw _privateConstructorUsedError; +} + +OrderItemDto _$OrderItemDtoFromJson(Map json) { + return _OrderItemDto.fromJson(json); +} + +/// @nodoc +mixin _$OrderItemDto { + @JsonKey(name: 'id') + String? get id => throw _privateConstructorUsedError; + @JsonKey(name: 'order_id') + String? get orderId => throw _privateConstructorUsedError; + @JsonKey(name: 'product_id') + String? get productId => throw _privateConstructorUsedError; + @JsonKey(name: 'product_name') + String? get productName => throw _privateConstructorUsedError; + @JsonKey(name: 'quantity') + int? get quantity => throw _privateConstructorUsedError; + @JsonKey(name: 'price') + int? get price => throw _privateConstructorUsedError; + @JsonKey(name: 'subtotal') + int? get subtotal => throw _privateConstructorUsedError; + @JsonKey(name: 'discount_amount') + int? get discountAmount => throw _privateConstructorUsedError; + @JsonKey(name: 'total') + int? get total => throw _privateConstructorUsedError; + @JsonKey(name: 'cost') + int? get cost => throw _privateConstructorUsedError; + @JsonKey(name: 'metadata') + Map? get metadata => throw _privateConstructorUsedError; + @JsonKey(name: 'created_at') + String? get createdAt => throw _privateConstructorUsedError; + @JsonKey(name: 'updated_at') + String? get updatedAt => throw _privateConstructorUsedError; + + /// Serializes this OrderItemDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of OrderItemDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $OrderItemDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderItemDtoCopyWith<$Res> { + factory $OrderItemDtoCopyWith( + OrderItemDto value, + $Res Function(OrderItemDto) then, + ) = _$OrderItemDtoCopyWithImpl<$Res, OrderItemDto>; + @useResult + $Res call({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'order_id') String? orderId, + @JsonKey(name: 'product_id') String? productId, + @JsonKey(name: 'product_name') String? productName, + @JsonKey(name: 'quantity') int? quantity, + @JsonKey(name: 'price') int? price, + @JsonKey(name: 'subtotal') int? subtotal, + @JsonKey(name: 'discount_amount') int? discountAmount, + @JsonKey(name: 'total') int? total, + @JsonKey(name: 'cost') int? cost, + @JsonKey(name: 'metadata') Map? metadata, + @JsonKey(name: 'created_at') String? createdAt, + @JsonKey(name: 'updated_at') String? updatedAt, + }); +} + +/// @nodoc +class _$OrderItemDtoCopyWithImpl<$Res, $Val extends OrderItemDto> + implements $OrderItemDtoCopyWith<$Res> { + _$OrderItemDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OrderItemDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderId = freezed, + Object? productId = freezed, + Object? productName = freezed, + Object? quantity = freezed, + Object? price = freezed, + Object? subtotal = freezed, + Object? discountAmount = freezed, + Object? total = freezed, + Object? cost = freezed, + Object? metadata = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + }) { + return _then( + _value.copyWith( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderId: freezed == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String?, + productId: freezed == productId + ? _value.productId + : productId // ignore: cast_nullable_to_non_nullable + as String?, + productName: freezed == productName + ? _value.productName + : productName // ignore: cast_nullable_to_non_nullable + as String?, + quantity: freezed == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int?, + price: freezed == price + ? _value.price + : price // ignore: cast_nullable_to_non_nullable + as int?, + subtotal: freezed == subtotal + ? _value.subtotal + : subtotal // ignore: cast_nullable_to_non_nullable + as int?, + discountAmount: freezed == discountAmount + ? _value.discountAmount + : discountAmount // ignore: cast_nullable_to_non_nullable + as int?, + total: freezed == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int?, + cost: freezed == cost + ? _value.cost + : cost // ignore: cast_nullable_to_non_nullable + as int?, + metadata: freezed == metadata + ? _value.metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map?, + createdAt: freezed == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String?, + updatedAt: freezed == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$OrderItemDtoImplCopyWith<$Res> + implements $OrderItemDtoCopyWith<$Res> { + factory _$$OrderItemDtoImplCopyWith( + _$OrderItemDtoImpl value, + $Res Function(_$OrderItemDtoImpl) then, + ) = __$$OrderItemDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'order_id') String? orderId, + @JsonKey(name: 'product_id') String? productId, + @JsonKey(name: 'product_name') String? productName, + @JsonKey(name: 'quantity') int? quantity, + @JsonKey(name: 'price') int? price, + @JsonKey(name: 'subtotal') int? subtotal, + @JsonKey(name: 'discount_amount') int? discountAmount, + @JsonKey(name: 'total') int? total, + @JsonKey(name: 'cost') int? cost, + @JsonKey(name: 'metadata') Map? metadata, + @JsonKey(name: 'created_at') String? createdAt, + @JsonKey(name: 'updated_at') String? updatedAt, + }); +} + +/// @nodoc +class __$$OrderItemDtoImplCopyWithImpl<$Res> + extends _$OrderItemDtoCopyWithImpl<$Res, _$OrderItemDtoImpl> + implements _$$OrderItemDtoImplCopyWith<$Res> { + __$$OrderItemDtoImplCopyWithImpl( + _$OrderItemDtoImpl _value, + $Res Function(_$OrderItemDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderItemDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderId = freezed, + Object? productId = freezed, + Object? productName = freezed, + Object? quantity = freezed, + Object? price = freezed, + Object? subtotal = freezed, + Object? discountAmount = freezed, + Object? total = freezed, + Object? cost = freezed, + Object? metadata = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + }) { + return _then( + _$OrderItemDtoImpl( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderId: freezed == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String?, + productId: freezed == productId + ? _value.productId + : productId // ignore: cast_nullable_to_non_nullable + as String?, + productName: freezed == productName + ? _value.productName + : productName // ignore: cast_nullable_to_non_nullable + as String?, + quantity: freezed == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int?, + price: freezed == price + ? _value.price + : price // ignore: cast_nullable_to_non_nullable + as int?, + subtotal: freezed == subtotal + ? _value.subtotal + : subtotal // ignore: cast_nullable_to_non_nullable + as int?, + discountAmount: freezed == discountAmount + ? _value.discountAmount + : discountAmount // ignore: cast_nullable_to_non_nullable + as int?, + total: freezed == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int?, + cost: freezed == cost + ? _value.cost + : cost // ignore: cast_nullable_to_non_nullable + as int?, + metadata: freezed == metadata + ? _value._metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map?, + createdAt: freezed == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String?, + updatedAt: freezed == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$OrderItemDtoImpl extends _OrderItemDto { + const _$OrderItemDtoImpl({ + @JsonKey(name: 'id') this.id, + @JsonKey(name: 'order_id') this.orderId, + @JsonKey(name: 'product_id') this.productId, + @JsonKey(name: 'product_name') this.productName, + @JsonKey(name: 'quantity') this.quantity, + @JsonKey(name: 'price') this.price, + @JsonKey(name: 'subtotal') this.subtotal, + @JsonKey(name: 'discount_amount') this.discountAmount, + @JsonKey(name: 'total') this.total, + @JsonKey(name: 'cost') this.cost, + @JsonKey(name: 'metadata') final Map? metadata, + @JsonKey(name: 'created_at') this.createdAt, + @JsonKey(name: 'updated_at') this.updatedAt, + }) : _metadata = metadata, + super._(); + + factory _$OrderItemDtoImpl.fromJson(Map json) => + _$$OrderItemDtoImplFromJson(json); + + @override + @JsonKey(name: 'id') + final String? id; + @override + @JsonKey(name: 'order_id') + final String? orderId; + @override + @JsonKey(name: 'product_id') + final String? productId; + @override + @JsonKey(name: 'product_name') + final String? productName; + @override + @JsonKey(name: 'quantity') + final int? quantity; + @override + @JsonKey(name: 'price') + final int? price; + @override + @JsonKey(name: 'subtotal') + final int? subtotal; + @override + @JsonKey(name: 'discount_amount') + final int? discountAmount; + @override + @JsonKey(name: 'total') + final int? total; + @override + @JsonKey(name: 'cost') + final int? cost; + final Map? _metadata; + @override + @JsonKey(name: 'metadata') + Map? get metadata { + final value = _metadata; + if (value == null) return null; + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + @override + @JsonKey(name: 'created_at') + final String? createdAt; + @override + @JsonKey(name: 'updated_at') + final String? updatedAt; + + @override + String toString() { + return 'OrderItemDto(id: $id, orderId: $orderId, productId: $productId, productName: $productName, quantity: $quantity, price: $price, subtotal: $subtotal, discountAmount: $discountAmount, total: $total, cost: $cost, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OrderItemDtoImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderId, orderId) || other.orderId == orderId) && + (identical(other.productId, productId) || + other.productId == productId) && + (identical(other.productName, productName) || + other.productName == productName) && + (identical(other.quantity, quantity) || + other.quantity == quantity) && + (identical(other.price, price) || other.price == price) && + (identical(other.subtotal, subtotal) || + other.subtotal == subtotal) && + (identical(other.discountAmount, discountAmount) || + other.discountAmount == discountAmount) && + (identical(other.total, total) || other.total == total) && + (identical(other.cost, cost) || other.cost == cost) && + const DeepCollectionEquality().equals(other._metadata, _metadata) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + id, + orderId, + productId, + productName, + quantity, + price, + subtotal, + discountAmount, + total, + cost, + const DeepCollectionEquality().hash(_metadata), + createdAt, + updatedAt, + ); + + /// Create a copy of OrderItemDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$OrderItemDtoImplCopyWith<_$OrderItemDtoImpl> get copyWith => + __$$OrderItemDtoImplCopyWithImpl<_$OrderItemDtoImpl>(this, _$identity); + + @override + Map toJson() { + return _$$OrderItemDtoImplToJson(this); + } +} + +abstract class _OrderItemDto extends OrderItemDto { + const factory _OrderItemDto({ + @JsonKey(name: 'id') final String? id, + @JsonKey(name: 'order_id') final String? orderId, + @JsonKey(name: 'product_id') final String? productId, + @JsonKey(name: 'product_name') final String? productName, + @JsonKey(name: 'quantity') final int? quantity, + @JsonKey(name: 'price') final int? price, + @JsonKey(name: 'subtotal') final int? subtotal, + @JsonKey(name: 'discount_amount') final int? discountAmount, + @JsonKey(name: 'total') final int? total, + @JsonKey(name: 'cost') final int? cost, + @JsonKey(name: 'metadata') final Map? metadata, + @JsonKey(name: 'created_at') final String? createdAt, + @JsonKey(name: 'updated_at') final String? updatedAt, + }) = _$OrderItemDtoImpl; + const _OrderItemDto._() : super._(); + + factory _OrderItemDto.fromJson(Map json) = + _$OrderItemDtoImpl.fromJson; + + @override + @JsonKey(name: 'id') + String? get id; + @override + @JsonKey(name: 'order_id') + String? get orderId; + @override + @JsonKey(name: 'product_id') + String? get productId; + @override + @JsonKey(name: 'product_name') + String? get productName; + @override + @JsonKey(name: 'quantity') + int? get quantity; + @override + @JsonKey(name: 'price') + int? get price; + @override + @JsonKey(name: 'subtotal') + int? get subtotal; + @override + @JsonKey(name: 'discount_amount') + int? get discountAmount; + @override + @JsonKey(name: 'total') + int? get total; + @override + @JsonKey(name: 'cost') + int? get cost; + @override + @JsonKey(name: 'metadata') + Map? get metadata; + @override + @JsonKey(name: 'created_at') + String? get createdAt; + @override + @JsonKey(name: 'updated_at') + String? get updatedAt; + + /// Create a copy of OrderItemDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$OrderItemDtoImplCopyWith<_$OrderItemDtoImpl> get copyWith => + throw _privateConstructorUsedError; +} + +OrderPaymentDto _$OrderPaymentDtoFromJson(Map json) { + return _OrderPaymentDto.fromJson(json); +} + +/// @nodoc +mixin _$OrderPaymentDto { + @JsonKey(name: 'id') + String? get id => throw _privateConstructorUsedError; + @JsonKey(name: 'order_id') + String? get orderId => throw _privateConstructorUsedError; + @JsonKey(name: 'payment_method_id') + String? get paymentMethodId => throw _privateConstructorUsedError; + @JsonKey(name: 'payment_method_name') + String? get paymentMethodName => throw _privateConstructorUsedError; + @JsonKey(name: 'payment_method_type') + String? get paymentMethodType => throw _privateConstructorUsedError; + @JsonKey(name: 'amount') + int? get amount => throw _privateConstructorUsedError; + @JsonKey(name: 'status') + String? get status => throw _privateConstructorUsedError; + @JsonKey(name: 'split_number') + int? get splitNumber => throw _privateConstructorUsedError; + @JsonKey(name: 'split_total') + int? get splitTotal => throw _privateConstructorUsedError; + @JsonKey(name: 'split_type') + String? get splitType => throw _privateConstructorUsedError; + @JsonKey(name: 'split_description') + String? get splitDescription => throw _privateConstructorUsedError; + @JsonKey(name: 'refund_amount') + int? get refundAmount => throw _privateConstructorUsedError; + @JsonKey(name: 'metadata') + Map? get metadata => throw _privateConstructorUsedError; + @JsonKey(name: 'created_at') + String? get createdAt => throw _privateConstructorUsedError; + @JsonKey(name: 'updated_at') + String? get updatedAt => throw _privateConstructorUsedError; + @JsonKey(name: 'payment_order_items') + List? get paymentOrderItems => + throw _privateConstructorUsedError; + + /// Serializes this OrderPaymentDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of OrderPaymentDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $OrderPaymentDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderPaymentDtoCopyWith<$Res> { + factory $OrderPaymentDtoCopyWith( + OrderPaymentDto value, + $Res Function(OrderPaymentDto) then, + ) = _$OrderPaymentDtoCopyWithImpl<$Res, OrderPaymentDto>; + @useResult + $Res call({ + @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_type') String? splitType, + @JsonKey(name: 'split_description') String? splitDescription, + @JsonKey(name: 'refund_amount') int? refundAmount, + @JsonKey(name: 'metadata') Map? metadata, + @JsonKey(name: 'created_at') String? createdAt, + @JsonKey(name: 'updated_at') String? updatedAt, + @JsonKey(name: 'payment_order_items') + List? paymentOrderItems, + }); +} + +/// @nodoc +class _$OrderPaymentDtoCopyWithImpl<$Res, $Val extends OrderPaymentDto> + implements $OrderPaymentDtoCopyWith<$Res> { + _$OrderPaymentDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OrderPaymentDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderId = freezed, + Object? paymentMethodId = freezed, + Object? paymentMethodName = freezed, + Object? paymentMethodType = freezed, + Object? amount = freezed, + Object? status = freezed, + Object? splitNumber = freezed, + Object? splitTotal = freezed, + Object? splitType = freezed, + Object? splitDescription = freezed, + Object? refundAmount = freezed, + Object? metadata = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + Object? paymentOrderItems = freezed, + }) { + return _then( + _value.copyWith( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderId: freezed == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodId: freezed == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodName: freezed == paymentMethodName + ? _value.paymentMethodName + : paymentMethodName // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodType: freezed == paymentMethodType + ? _value.paymentMethodType + : paymentMethodType // ignore: cast_nullable_to_non_nullable + as String?, + amount: freezed == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + splitNumber: freezed == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int?, + splitTotal: freezed == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int?, + splitType: freezed == splitType + ? _value.splitType + : splitType // ignore: cast_nullable_to_non_nullable + as String?, + splitDescription: freezed == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String?, + refundAmount: freezed == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int?, + metadata: freezed == metadata + ? _value.metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map?, + createdAt: freezed == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String?, + updatedAt: freezed == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String?, + paymentOrderItems: freezed == paymentOrderItems + ? _value.paymentOrderItems + : paymentOrderItems // ignore: cast_nullable_to_non_nullable + as List?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$OrderPaymentDtoImplCopyWith<$Res> + implements $OrderPaymentDtoCopyWith<$Res> { + factory _$$OrderPaymentDtoImplCopyWith( + _$OrderPaymentDtoImpl value, + $Res Function(_$OrderPaymentDtoImpl) then, + ) = __$$OrderPaymentDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @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_type') String? splitType, + @JsonKey(name: 'split_description') String? splitDescription, + @JsonKey(name: 'refund_amount') int? refundAmount, + @JsonKey(name: 'metadata') Map? metadata, + @JsonKey(name: 'created_at') String? createdAt, + @JsonKey(name: 'updated_at') String? updatedAt, + @JsonKey(name: 'payment_order_items') + List? paymentOrderItems, + }); +} + +/// @nodoc +class __$$OrderPaymentDtoImplCopyWithImpl<$Res> + extends _$OrderPaymentDtoCopyWithImpl<$Res, _$OrderPaymentDtoImpl> + implements _$$OrderPaymentDtoImplCopyWith<$Res> { + __$$OrderPaymentDtoImplCopyWithImpl( + _$OrderPaymentDtoImpl _value, + $Res Function(_$OrderPaymentDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderPaymentDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderId = freezed, + Object? paymentMethodId = freezed, + Object? paymentMethodName = freezed, + Object? paymentMethodType = freezed, + Object? amount = freezed, + Object? status = freezed, + Object? splitNumber = freezed, + Object? splitTotal = freezed, + Object? splitType = freezed, + Object? splitDescription = freezed, + Object? refundAmount = freezed, + Object? metadata = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + Object? paymentOrderItems = freezed, + }) { + return _then( + _$OrderPaymentDtoImpl( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderId: freezed == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodId: freezed == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodName: freezed == paymentMethodName + ? _value.paymentMethodName + : paymentMethodName // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodType: freezed == paymentMethodType + ? _value.paymentMethodType + : paymentMethodType // ignore: cast_nullable_to_non_nullable + as String?, + amount: freezed == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + splitNumber: freezed == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int?, + splitTotal: freezed == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int?, + splitType: freezed == splitType + ? _value.splitType + : splitType // ignore: cast_nullable_to_non_nullable + as String?, + splitDescription: freezed == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String?, + refundAmount: freezed == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int?, + metadata: freezed == metadata + ? _value._metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map?, + createdAt: freezed == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String?, + updatedAt: freezed == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String?, + paymentOrderItems: freezed == paymentOrderItems + ? _value._paymentOrderItems + : paymentOrderItems // ignore: cast_nullable_to_non_nullable + as List?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$OrderPaymentDtoImpl extends _OrderPaymentDto { + const _$OrderPaymentDtoImpl({ + @JsonKey(name: 'id') this.id, + @JsonKey(name: 'order_id') this.orderId, + @JsonKey(name: 'payment_method_id') this.paymentMethodId, + @JsonKey(name: 'payment_method_name') this.paymentMethodName, + @JsonKey(name: 'payment_method_type') this.paymentMethodType, + @JsonKey(name: 'amount') this.amount, + @JsonKey(name: 'status') this.status, + @JsonKey(name: 'split_number') this.splitNumber, + @JsonKey(name: 'split_total') this.splitTotal, + @JsonKey(name: 'split_type') this.splitType, + @JsonKey(name: 'split_description') this.splitDescription, + @JsonKey(name: 'refund_amount') this.refundAmount, + @JsonKey(name: 'metadata') final Map? metadata, + @JsonKey(name: 'created_at') this.createdAt, + @JsonKey(name: 'updated_at') this.updatedAt, + @JsonKey(name: 'payment_order_items') + final List? paymentOrderItems, + }) : _metadata = metadata, + _paymentOrderItems = paymentOrderItems, + super._(); + + factory _$OrderPaymentDtoImpl.fromJson(Map json) => + _$$OrderPaymentDtoImplFromJson(json); + + @override + @JsonKey(name: 'id') + final String? id; + @override + @JsonKey(name: 'order_id') + final String? orderId; + @override + @JsonKey(name: 'payment_method_id') + final String? paymentMethodId; + @override + @JsonKey(name: 'payment_method_name') + final String? paymentMethodName; + @override + @JsonKey(name: 'payment_method_type') + final String? paymentMethodType; + @override + @JsonKey(name: 'amount') + final int? amount; + @override + @JsonKey(name: 'status') + final String? status; + @override + @JsonKey(name: 'split_number') + final int? splitNumber; + @override + @JsonKey(name: 'split_total') + final int? splitTotal; + @override + @JsonKey(name: 'split_type') + final String? splitType; + @override + @JsonKey(name: 'split_description') + final String? splitDescription; + @override + @JsonKey(name: 'refund_amount') + final int? refundAmount; + final Map? _metadata; + @override + @JsonKey(name: 'metadata') + Map? get metadata { + final value = _metadata; + if (value == null) return null; + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + @override + @JsonKey(name: 'created_at') + final String? createdAt; + @override + @JsonKey(name: 'updated_at') + final String? updatedAt; + final List? _paymentOrderItems; + @override + @JsonKey(name: 'payment_order_items') + List? get paymentOrderItems { + final value = _paymentOrderItems; + if (value == null) return null; + if (_paymentOrderItems is EqualUnmodifiableListView) + return _paymentOrderItems; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + String toString() { + return 'OrderPaymentDto(id: $id, orderId: $orderId, paymentMethodId: $paymentMethodId, paymentMethodName: $paymentMethodName, paymentMethodType: $paymentMethodType, amount: $amount, status: $status, splitNumber: $splitNumber, splitTotal: $splitTotal, splitType: $splitType, splitDescription: $splitDescription, refundAmount: $refundAmount, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt, paymentOrderItems: $paymentOrderItems)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OrderPaymentDtoImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderId, orderId) || other.orderId == orderId) && + (identical(other.paymentMethodId, paymentMethodId) || + other.paymentMethodId == paymentMethodId) && + (identical(other.paymentMethodName, paymentMethodName) || + other.paymentMethodName == paymentMethodName) && + (identical(other.paymentMethodType, paymentMethodType) || + other.paymentMethodType == paymentMethodType) && + (identical(other.amount, amount) || other.amount == amount) && + (identical(other.status, status) || other.status == status) && + (identical(other.splitNumber, splitNumber) || + other.splitNumber == splitNumber) && + (identical(other.splitTotal, splitTotal) || + other.splitTotal == splitTotal) && + (identical(other.splitType, splitType) || + other.splitType == splitType) && + (identical(other.splitDescription, splitDescription) || + other.splitDescription == splitDescription) && + (identical(other.refundAmount, refundAmount) || + other.refundAmount == refundAmount) && + const DeepCollectionEquality().equals(other._metadata, _metadata) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt) && + const DeepCollectionEquality().equals( + other._paymentOrderItems, + _paymentOrderItems, + )); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + id, + orderId, + paymentMethodId, + paymentMethodName, + paymentMethodType, + amount, + status, + splitNumber, + splitTotal, + splitType, + splitDescription, + refundAmount, + const DeepCollectionEquality().hash(_metadata), + createdAt, + updatedAt, + const DeepCollectionEquality().hash(_paymentOrderItems), + ); + + /// Create a copy of OrderPaymentDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$OrderPaymentDtoImplCopyWith<_$OrderPaymentDtoImpl> get copyWith => + __$$OrderPaymentDtoImplCopyWithImpl<_$OrderPaymentDtoImpl>( + this, + _$identity, + ); + + @override + Map toJson() { + return _$$OrderPaymentDtoImplToJson(this); + } +} + +abstract class _OrderPaymentDto extends OrderPaymentDto { + const factory _OrderPaymentDto({ + @JsonKey(name: 'id') final String? id, + @JsonKey(name: 'order_id') final String? orderId, + @JsonKey(name: 'payment_method_id') final String? paymentMethodId, + @JsonKey(name: 'payment_method_name') final String? paymentMethodName, + @JsonKey(name: 'payment_method_type') final String? paymentMethodType, + @JsonKey(name: 'amount') final int? amount, + @JsonKey(name: 'status') final String? status, + @JsonKey(name: 'split_number') final int? splitNumber, + @JsonKey(name: 'split_total') final int? splitTotal, + @JsonKey(name: 'split_type') final String? splitType, + @JsonKey(name: 'split_description') final String? splitDescription, + @JsonKey(name: 'refund_amount') final int? refundAmount, + @JsonKey(name: 'metadata') final Map? metadata, + @JsonKey(name: 'created_at') final String? createdAt, + @JsonKey(name: 'updated_at') final String? updatedAt, + @JsonKey(name: 'payment_order_items') + final List? paymentOrderItems, + }) = _$OrderPaymentDtoImpl; + const _OrderPaymentDto._() : super._(); + + factory _OrderPaymentDto.fromJson(Map json) = + _$OrderPaymentDtoImpl.fromJson; + + @override + @JsonKey(name: 'id') + String? get id; + @override + @JsonKey(name: 'order_id') + String? get orderId; + @override + @JsonKey(name: 'payment_method_id') + String? get paymentMethodId; + @override + @JsonKey(name: 'payment_method_name') + String? get paymentMethodName; + @override + @JsonKey(name: 'payment_method_type') + String? get paymentMethodType; + @override + @JsonKey(name: 'amount') + int? get amount; + @override + @JsonKey(name: 'status') + String? get status; + @override + @JsonKey(name: 'split_number') + int? get splitNumber; + @override + @JsonKey(name: 'split_total') + int? get splitTotal; + @override + @JsonKey(name: 'split_type') + String? get splitType; + @override + @JsonKey(name: 'split_description') + String? get splitDescription; + @override + @JsonKey(name: 'refund_amount') + int? get refundAmount; + @override + @JsonKey(name: 'metadata') + Map? get metadata; + @override + @JsonKey(name: 'created_at') + String? get createdAt; + @override + @JsonKey(name: 'updated_at') + String? get updatedAt; + @override + @JsonKey(name: 'payment_order_items') + List? get paymentOrderItems; + + /// Create a copy of OrderPaymentDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$OrderPaymentDtoImplCopyWith<_$OrderPaymentDtoImpl> get copyWith => + throw _privateConstructorUsedError; +} + +PaymentOrderItemDto _$PaymentOrderItemDtoFromJson(Map json) { + return _PaymentOrderItemDto.fromJson(json); +} + +/// @nodoc +mixin _$PaymentOrderItemDto { + @JsonKey(name: 'id') + String? get id => throw _privateConstructorUsedError; + @JsonKey(name: 'order_payment_id') + String? get orderPaymentId => throw _privateConstructorUsedError; + @JsonKey(name: 'order_item_id') + String? get orderItemId => throw _privateConstructorUsedError; + @JsonKey(name: 'amount') + int? get amount => throw _privateConstructorUsedError; + @JsonKey(name: 'refund_amount') + int? get refundAmount => throw _privateConstructorUsedError; + @JsonKey(name: 'created_at') + String? get createdAt => throw _privateConstructorUsedError; + @JsonKey(name: 'updated_at') + String? get updatedAt => throw _privateConstructorUsedError; + + /// Serializes this PaymentOrderItemDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PaymentOrderItemDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PaymentOrderItemDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PaymentOrderItemDtoCopyWith<$Res> { + factory $PaymentOrderItemDtoCopyWith( + PaymentOrderItemDto value, + $Res Function(PaymentOrderItemDto) then, + ) = _$PaymentOrderItemDtoCopyWithImpl<$Res, PaymentOrderItemDto>; + @useResult + $Res call({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'order_payment_id') String? orderPaymentId, + @JsonKey(name: 'order_item_id') String? orderItemId, + @JsonKey(name: 'amount') int? amount, + @JsonKey(name: 'refund_amount') int? refundAmount, + @JsonKey(name: 'created_at') String? createdAt, + @JsonKey(name: 'updated_at') String? updatedAt, + }); +} + +/// @nodoc +class _$PaymentOrderItemDtoCopyWithImpl<$Res, $Val extends PaymentOrderItemDto> + implements $PaymentOrderItemDtoCopyWith<$Res> { + _$PaymentOrderItemDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PaymentOrderItemDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderPaymentId = freezed, + Object? orderItemId = freezed, + Object? amount = freezed, + Object? refundAmount = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + }) { + return _then( + _value.copyWith( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderPaymentId: freezed == orderPaymentId + ? _value.orderPaymentId + : orderPaymentId // ignore: cast_nullable_to_non_nullable + as String?, + orderItemId: freezed == orderItemId + ? _value.orderItemId + : orderItemId // ignore: cast_nullable_to_non_nullable + as String?, + amount: freezed == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int?, + refundAmount: freezed == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int?, + createdAt: freezed == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String?, + updatedAt: freezed == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PaymentOrderItemDtoImplCopyWith<$Res> + implements $PaymentOrderItemDtoCopyWith<$Res> { + factory _$$PaymentOrderItemDtoImplCopyWith( + _$PaymentOrderItemDtoImpl value, + $Res Function(_$PaymentOrderItemDtoImpl) then, + ) = __$$PaymentOrderItemDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'order_payment_id') String? orderPaymentId, + @JsonKey(name: 'order_item_id') String? orderItemId, + @JsonKey(name: 'amount') int? amount, + @JsonKey(name: 'refund_amount') int? refundAmount, + @JsonKey(name: 'created_at') String? createdAt, + @JsonKey(name: 'updated_at') String? updatedAt, + }); +} + +/// @nodoc +class __$$PaymentOrderItemDtoImplCopyWithImpl<$Res> + extends _$PaymentOrderItemDtoCopyWithImpl<$Res, _$PaymentOrderItemDtoImpl> + implements _$$PaymentOrderItemDtoImplCopyWith<$Res> { + __$$PaymentOrderItemDtoImplCopyWithImpl( + _$PaymentOrderItemDtoImpl _value, + $Res Function(_$PaymentOrderItemDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PaymentOrderItemDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderPaymentId = freezed, + Object? orderItemId = freezed, + Object? amount = freezed, + Object? refundAmount = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + }) { + return _then( + _$PaymentOrderItemDtoImpl( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderPaymentId: freezed == orderPaymentId + ? _value.orderPaymentId + : orderPaymentId // ignore: cast_nullable_to_non_nullable + as String?, + orderItemId: freezed == orderItemId + ? _value.orderItemId + : orderItemId // ignore: cast_nullable_to_non_nullable + as String?, + amount: freezed == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int?, + refundAmount: freezed == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int?, + createdAt: freezed == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String?, + updatedAt: freezed == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$PaymentOrderItemDtoImpl extends _PaymentOrderItemDto { + const _$PaymentOrderItemDtoImpl({ + @JsonKey(name: 'id') this.id, + @JsonKey(name: 'order_payment_id') this.orderPaymentId, + @JsonKey(name: 'order_item_id') this.orderItemId, + @JsonKey(name: 'amount') this.amount, + @JsonKey(name: 'refund_amount') this.refundAmount, + @JsonKey(name: 'created_at') this.createdAt, + @JsonKey(name: 'updated_at') this.updatedAt, + }) : super._(); + + factory _$PaymentOrderItemDtoImpl.fromJson(Map json) => + _$$PaymentOrderItemDtoImplFromJson(json); + + @override + @JsonKey(name: 'id') + final String? id; + @override + @JsonKey(name: 'order_payment_id') + final String? orderPaymentId; + @override + @JsonKey(name: 'order_item_id') + final String? orderItemId; + @override + @JsonKey(name: 'amount') + final int? amount; + @override + @JsonKey(name: 'refund_amount') + final int? refundAmount; + @override + @JsonKey(name: 'created_at') + final String? createdAt; + @override + @JsonKey(name: 'updated_at') + final String? updatedAt; + + @override + String toString() { + return 'PaymentOrderItemDto(id: $id, orderPaymentId: $orderPaymentId, orderItemId: $orderItemId, amount: $amount, refundAmount: $refundAmount, createdAt: $createdAt, updatedAt: $updatedAt)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentOrderItemDtoImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderPaymentId, orderPaymentId) || + other.orderPaymentId == orderPaymentId) && + (identical(other.orderItemId, orderItemId) || + other.orderItemId == orderItemId) && + (identical(other.amount, amount) || other.amount == amount) && + (identical(other.refundAmount, refundAmount) || + other.refundAmount == refundAmount) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + id, + orderPaymentId, + orderItemId, + amount, + refundAmount, + createdAt, + updatedAt, + ); + + /// Create a copy of PaymentOrderItemDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PaymentOrderItemDtoImplCopyWith<_$PaymentOrderItemDtoImpl> get copyWith => + __$$PaymentOrderItemDtoImplCopyWithImpl<_$PaymentOrderItemDtoImpl>( + this, + _$identity, + ); + + @override + Map toJson() { + return _$$PaymentOrderItemDtoImplToJson(this); + } +} + +abstract class _PaymentOrderItemDto extends PaymentOrderItemDto { + const factory _PaymentOrderItemDto({ + @JsonKey(name: 'id') final String? id, + @JsonKey(name: 'order_payment_id') final String? orderPaymentId, + @JsonKey(name: 'order_item_id') final String? orderItemId, + @JsonKey(name: 'amount') final int? amount, + @JsonKey(name: 'refund_amount') final int? refundAmount, + @JsonKey(name: 'created_at') final String? createdAt, + @JsonKey(name: 'updated_at') final String? updatedAt, + }) = _$PaymentOrderItemDtoImpl; + const _PaymentOrderItemDto._() : super._(); + + factory _PaymentOrderItemDto.fromJson(Map json) = + _$PaymentOrderItemDtoImpl.fromJson; + + @override + @JsonKey(name: 'id') + String? get id; + @override + @JsonKey(name: 'order_payment_id') + String? get orderPaymentId; + @override + @JsonKey(name: 'order_item_id') + String? get orderItemId; + @override + @JsonKey(name: 'amount') + int? get amount; + @override + @JsonKey(name: 'refund_amount') + int? get refundAmount; + @override + @JsonKey(name: 'created_at') + String? get createdAt; + @override + @JsonKey(name: 'updated_at') + String? get updatedAt; + + /// Create a copy of PaymentOrderItemDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PaymentOrderItemDtoImplCopyWith<_$PaymentOrderItemDtoImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/infrastructure/order/order_dtos.g.dart b/lib/infrastructure/order/order_dtos.g.dart new file mode 100644 index 0000000..de95ff2 --- /dev/null +++ b/lib/infrastructure/order/order_dtos.g.dart @@ -0,0 +1,173 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'order_dtos.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$OrderDtoImpl _$$OrderDtoImplFromJson(Map json) => + _$OrderDtoImpl( + id: json['id'] as String?, + orderNumber: json['order_number'] as String?, + outletId: json['outlet_id'] as String?, + userId: json['user_id'] as String?, + tableNumber: json['table_number'] as String?, + orderType: json['order_type'] as String?, + status: json['status'] as String?, + subtotal: (json['subtotal'] as num?)?.toInt(), + taxAmount: (json['tax_amount'] as num?)?.toInt(), + discountAmount: (json['discount_amount'] as num?)?.toInt(), + totalAmount: (json['total_amount'] as num?)?.toInt(), + totalCost: (json['total_cost'] as num?)?.toInt(), + remainingAmount: (json['remaining_amount'] as num?)?.toInt(), + paymentStatus: json['payment_status'] as String?, + refundAmount: (json['refund_amount'] as num?)?.toInt(), + isVoid: json['is_void'] as bool?, + isRefund: json['is_refund'] as bool?, + notes: json['notes'] as String?, + metadata: json['metadata'] as Map?, + createdAt: json['created_at'] as String?, + updatedAt: json['updated_at'] as String?, + orderItems: (json['order_items'] as List?) + ?.map((e) => OrderItemDto.fromJson(e as Map)) + .toList(), + payments: (json['payments'] as List?) + ?.map((e) => OrderPaymentDto.fromJson(e as Map)) + .toList(), + totalPaid: (json['total_paid'] as num?)?.toInt(), + paymentCount: (json['payment_count'] as num?)?.toInt(), + splitType: json['split_type'] as String?, + ); + +Map _$$OrderDtoImplToJson(_$OrderDtoImpl instance) => + { + 'id': instance.id, + 'order_number': instance.orderNumber, + 'outlet_id': instance.outletId, + 'user_id': instance.userId, + 'table_number': instance.tableNumber, + 'order_type': instance.orderType, + 'status': instance.status, + 'subtotal': instance.subtotal, + 'tax_amount': instance.taxAmount, + 'discount_amount': instance.discountAmount, + 'total_amount': instance.totalAmount, + 'total_cost': instance.totalCost, + 'remaining_amount': instance.remainingAmount, + 'payment_status': instance.paymentStatus, + 'refund_amount': instance.refundAmount, + 'is_void': instance.isVoid, + 'is_refund': instance.isRefund, + 'notes': instance.notes, + 'metadata': instance.metadata, + 'created_at': instance.createdAt, + 'updated_at': instance.updatedAt, + 'order_items': instance.orderItems, + 'payments': instance.payments, + 'total_paid': instance.totalPaid, + 'payment_count': instance.paymentCount, + 'split_type': instance.splitType, + }; + +_$OrderItemDtoImpl _$$OrderItemDtoImplFromJson(Map json) => + _$OrderItemDtoImpl( + id: json['id'] as String?, + orderId: json['order_id'] as String?, + productId: json['product_id'] as String?, + productName: json['product_name'] as String?, + quantity: (json['quantity'] as num?)?.toInt(), + price: (json['price'] as num?)?.toInt(), + subtotal: (json['subtotal'] as num?)?.toInt(), + discountAmount: (json['discount_amount'] as num?)?.toInt(), + total: (json['total'] as num?)?.toInt(), + cost: (json['cost'] as num?)?.toInt(), + metadata: json['metadata'] as Map?, + createdAt: json['created_at'] as String?, + updatedAt: json['updated_at'] as String?, + ); + +Map _$$OrderItemDtoImplToJson(_$OrderItemDtoImpl instance) => + { + 'id': instance.id, + 'order_id': instance.orderId, + 'product_id': instance.productId, + 'product_name': instance.productName, + 'quantity': instance.quantity, + 'price': instance.price, + 'subtotal': instance.subtotal, + 'discount_amount': instance.discountAmount, + 'total': instance.total, + 'cost': instance.cost, + 'metadata': instance.metadata, + 'created_at': instance.createdAt, + 'updated_at': instance.updatedAt, + }; + +_$OrderPaymentDtoImpl _$$OrderPaymentDtoImplFromJson( + Map json, +) => _$OrderPaymentDtoImpl( + 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(), + splitType: json['split_type'] as String?, + splitDescription: json['split_description'] as String?, + refundAmount: (json['refund_amount'] as num?)?.toInt(), + metadata: json['metadata'] as Map?, + createdAt: json['created_at'] as String?, + updatedAt: json['updated_at'] as String?, + paymentOrderItems: (json['payment_order_items'] as List?) + ?.map((e) => PaymentOrderItemDto.fromJson(e as Map)) + .toList(), +); + +Map _$$OrderPaymentDtoImplToJson( + _$OrderPaymentDtoImpl instance, +) => { + '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_type': instance.splitType, + 'split_description': instance.splitDescription, + 'refund_amount': instance.refundAmount, + 'metadata': instance.metadata, + 'created_at': instance.createdAt, + 'updated_at': instance.updatedAt, + 'payment_order_items': instance.paymentOrderItems, +}; + +_$PaymentOrderItemDtoImpl _$$PaymentOrderItemDtoImplFromJson( + Map json, +) => _$PaymentOrderItemDtoImpl( + id: json['id'] as String?, + orderPaymentId: json['order_payment_id'] as String?, + orderItemId: json['order_item_id'] as String?, + amount: (json['amount'] as num?)?.toInt(), + refundAmount: (json['refund_amount'] as num?)?.toInt(), + createdAt: json['created_at'] as String?, + updatedAt: json['updated_at'] as String?, +); + +Map _$$PaymentOrderItemDtoImplToJson( + _$PaymentOrderItemDtoImpl instance, +) => { + 'id': instance.id, + 'order_payment_id': instance.orderPaymentId, + 'order_item_id': instance.orderItemId, + 'amount': instance.amount, + 'refund_amount': instance.refundAmount, + 'created_at': instance.createdAt, + 'updated_at': instance.updatedAt, +}; diff --git a/lib/infrastructure/order/repositories/order_repository.dart b/lib/infrastructure/order/repositories/order_repository.dart new file mode 100644 index 0000000..a80a321 --- /dev/null +++ b/lib/infrastructure/order/repositories/order_repository.dart @@ -0,0 +1,43 @@ +import 'dart:developer'; + +import 'package:dartz/dartz.dart' hide Order; +import 'package:injectable/injectable.dart' hide Order; + +import '../../../domain/order/order.dart'; +import '../datasource/remote_data_provider.dart'; + +@Injectable(as: IOrderRepository) +class OrderRepository implements IOrderRepository { + final OrderRemoteDataProvider _dataProvider; + final String _logName = 'OrderRepository'; + + OrderRepository(this._dataProvider); + + @override + Future>> get({ + int page = 1, + int limit = 20, + String? status, + String? search, + }) async { + try { + final result = await _dataProvider.fetch( + page: page, + limit: limit, + status: status, + search: search, + ); + + if (result.hasError) { + return left(result.error!); + } + + final auth = result.data!.map((e) => e.toDomain()).toList(); + + return right(auth); + } catch (e, s) { + log('getOrderError', name: _logName, error: e, stackTrace: s); + return left(const OrderFailure.unexpectedError()); + } + } +} diff --git a/lib/injection.config.dart b/lib/injection.config.dart index ebc0cf1..78b31ec 100644 --- a/lib/injection.config.dart +++ b/lib/injection.config.dart @@ -34,6 +34,8 @@ import 'package:apskel_owner_flutter/application/customer/customer_loader/custom as _i972; import 'package:apskel_owner_flutter/application/language/language_bloc.dart' as _i455; +import 'package:apskel_owner_flutter/application/order/order_loader/order_loader_bloc.dart' + as _i1058; import 'package:apskel_owner_flutter/application/product/product_loader/product_loader_bloc.dart' as _i458; import 'package:apskel_owner_flutter/common/api/api_client.dart' as _i115; @@ -50,6 +52,7 @@ import 'package:apskel_owner_flutter/domain/analytic/repositories/i_analytic_rep import 'package:apskel_owner_flutter/domain/auth/auth.dart' as _i49; import 'package:apskel_owner_flutter/domain/category/category.dart' as _i1020; import 'package:apskel_owner_flutter/domain/customer/customer.dart' as _i48; +import 'package:apskel_owner_flutter/domain/order/order.dart' as _i219; import 'package:apskel_owner_flutter/domain/product/product.dart' as _i419; import 'package:apskel_owner_flutter/env.dart' as _i6; import 'package:apskel_owner_flutter/infrastructure/analytic/datasource/remote_data_provider.dart' @@ -70,6 +73,10 @@ import 'package:apskel_owner_flutter/infrastructure/customer/datasources/remote_ as _i1006; import 'package:apskel_owner_flutter/infrastructure/customer/repositories/customer_repository.dart' as _i550; +import 'package:apskel_owner_flutter/infrastructure/order/datasource/remote_data_provider.dart' + as _i130; +import 'package:apskel_owner_flutter/infrastructure/order/repositories/order_repository.dart' + as _i641; import 'package:apskel_owner_flutter/infrastructure/product/datasources/remote_data_provider.dart' as _i823; import 'package:apskel_owner_flutter/infrastructure/product/repositories/product_repository.dart' @@ -138,9 +145,15 @@ extension GetItInjectableX on _i174.GetIt { gh.factory<_i1006.CustomerRemoteDataProvider>( () => _i1006.CustomerRemoteDataProvider(gh<_i115.ApiClient>()), ); + gh.factory<_i130.OrderRemoteDataProvider>( + () => _i130.OrderRemoteDataProvider(gh<_i115.ApiClient>()), + ); gh.factory<_i48.ICustomerRepository>( () => _i550.CustomerRepository(gh<_i1006.CustomerRemoteDataProvider>()), ); + gh.factory<_i219.IOrderRepository>( + () => _i641.OrderRepository(gh<_i130.OrderRemoteDataProvider>()), + ); gh.factory<_i49.IAuthRepository>( () => _i1035.AuthRepository( gh<_i991.AuthLocalDataProvider>(), @@ -200,6 +213,9 @@ extension GetItInjectableX on _i174.GetIt { gh.factory<_i574.LogoutFormBloc>( () => _i574.LogoutFormBloc(gh<_i49.IAuthRepository>()), ); + gh.factory<_i1058.OrderLoaderBloc>( + () => _i1058.OrderLoaderBloc(gh<_i219.IOrderRepository>()), + ); return this; } } diff --git a/lib/presentation/pages/order/order_page.dart b/lib/presentation/pages/order/order_page.dart index 5d65e02..37bc786 100644 --- a/lib/presentation/pages/order/order_page.dart +++ b/lib/presentation/pages/order/order_page.dart @@ -1,20 +1,32 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:line_icons/line_icons.dart'; +import '../../../application/order/order_loader/order_loader_bloc.dart'; import '../../../common/theme/theme.dart'; +import '../../../injection.dart'; import '../../components/appbar/appbar.dart'; import '../../components/button/button.dart'; import '../../components/spacer/spacer.dart'; +import '../../components/widgets/empty_widget.dart'; import 'widgets/status_tile.dart'; import 'widgets/order_tile.dart'; @RoutePage() -class OrderPage extends StatefulWidget { +class OrderPage extends StatefulWidget implements AutoRouteWrapper { const OrderPage({super.key}); @override State createState() => _OrderPageState(); + + @override + Widget wrappedRoute(BuildContext context) => BlocProvider( + create: (_) => + getIt() + ..add(OrderLoaderEvent.fetched(isRefresh: true)), + child: this, + ); } class _OrderPageState extends State with TickerProviderStateMixin { @@ -22,15 +34,11 @@ class _OrderPageState extends State with TickerProviderStateMixin { late AnimationController _slideController; late Animation _fadeAnimation; late Animation _slideAnimation; + final ScrollController _scrollController = ScrollController(); // Filter state String selectedFilter = 'All'; - final List filterOptions = [ - 'All', - 'Completed', - 'Pending', - 'Refunded', - ]; + final List filterOptions = ['All', 'Completed', 'Pending']; @override void initState() { @@ -66,202 +74,168 @@ class _OrderPageState extends State with TickerProviderStateMixin { super.dispose(); } - final sampleTransactions = [ - Transaction( - id: 'TXN001', - customerName: 'John Doe', - date: DateTime.now().subtract(const Duration(hours: 2)), - totalAmount: 125000, - itemCount: 3, - paymentMethod: 'Cash', - status: TransactionStatus.completed, - receiptNumber: 'RCP-2024-001', - ), - Transaction( - id: 'TXN002', - customerName: 'Jane Smith', - date: DateTime.now().subtract(const Duration(hours: 5)), - totalAmount: 87500, - itemCount: 2, - paymentMethod: 'QRIS', - status: TransactionStatus.pending, - receiptNumber: 'RCP-2024-002', - ), - Transaction( - id: 'TXN003', - customerName: 'Bob Johnson', - date: DateTime.now().subtract(const Duration(days: 1)), - totalAmount: 250000, - itemCount: 5, - paymentMethod: 'Credit Card', - status: TransactionStatus.refunded, - receiptNumber: 'RCP-2024-003', - ), - ]; - - // Filter transactions based on selected status - List get filteredTransactions { - if (selectedFilter == 'All') { - return sampleTransactions; - } - - TransactionStatus? filterStatus; - switch (selectedFilter) { - case 'Completed': - filterStatus = TransactionStatus.completed; - break; - case 'Pending': - filterStatus = TransactionStatus.pending; - break; - case 'Refunded': - filterStatus = TransactionStatus.refunded; - break; - } - - return sampleTransactions - .where((transaction) => transaction.status == filterStatus) - .toList(); - } - - // Build filter chip - @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColor.background, - body: CustomScrollView( - slivers: [ - // Custom App Bar with Hero Effect - SliverAppBar( - expandedHeight: 120, - floating: true, - pinned: true, - backgroundColor: AppColor.primary, - centerTitle: false, - flexibleSpace: CustomAppBar(title: 'Order', isBack: false), - actions: [ - ActionIconButton(onTap: () {}, icon: LineIcons.filter), - SpaceWidth(8), - ], - ), + body: BlocListener( + listenWhen: (p, c) => p.status != c.status, + listener: (context, state) { + context.read().add( + OrderLoaderEvent.fetched(isRefresh: true), + ); + }, + child: BlocBuilder( + builder: (context, state) { + return NotificationListener( + onNotification: (notification) { + if (notification is ScrollEndNotification && + _scrollController.position.extentAfter == 0) { + context.read().add( + OrderLoaderEvent.fetched(), + ); + return true; + } - // Pinned Filter Section - SliverPersistentHeader( - pinned: true, - delegate: _FilterHeaderDelegate( - child: Container( - color: AppColor.background, - padding: EdgeInsets.fromLTRB( - AppValue.padding, - 10, - AppValue.padding, - 10, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - children: filterOptions.map((option) { - final index = filterOptions.indexOf(option); - return Padding( - padding: EdgeInsets.only( - right: index < filterOptions.length - 1 ? 8 : 0, - ), - child: OrderStatusTile( - label: option, - isSelected: option == selectedFilter, - onSelected: (isSelected) { - if (isSelected) { - setState(() { - selectedFilter = option; - }); - } - }, - ), - ); - }).toList(), - ), - ), - ], - ), - ), - ), - ), + return true; + }, + child: CustomScrollView( + controller: _scrollController, + slivers: [ + // Custom App Bar with Hero Effect + SliverAppBar( + expandedHeight: 120, + floating: true, + pinned: true, + backgroundColor: AppColor.primary, + centerTitle: false, + flexibleSpace: CustomAppBar(title: 'Order', isBack: false), + actions: [ + ActionIconButton(onTap: () {}, icon: LineIcons.filter), + SpaceWidth(8), + ], + ), - // Content - SliverPadding( - padding: EdgeInsets.all(AppValue.padding), - sliver: SliverList( - delegate: SliverChildListDelegate([ - FadeTransition( - opacity: _fadeAnimation, - child: SlideTransition( - position: _slideAnimation, - child: Column( - children: [ - // Show filtered transaction count - if (selectedFilter != 'All') - Padding( - padding: const EdgeInsets.only(bottom: 16), - child: Row( - children: [ - Text( - '${filteredTransactions.length} ${selectedFilter.toLowerCase()} transaction${filteredTransactions.length != 1 ? 's' : ''}', - style: TextStyle( - color: AppColor.textSecondary, - fontSize: 14, - ), - ), - ], - ), - ), - - // Transaction List - filteredTransactions.isEmpty - ? Container( - padding: const EdgeInsets.symmetric( - vertical: 40, - ), - child: Column( - children: [ - Icon( - LineIcons.receipt, - size: 64, - color: AppColor.textSecondary.withOpacity( - 0.5, - ), + // Pinned Filter Section + SliverPersistentHeader( + pinned: true, + delegate: _FilterHeaderDelegate( + child: Container( + color: AppColor.background, + padding: EdgeInsets.fromLTRB( + AppValue.padding, + 10, + AppValue.padding, + 10, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: filterOptions.map((option) { + final index = filterOptions.indexOf(option); + return Padding( + padding: EdgeInsets.only( + right: index < filterOptions.length - 1 + ? 8 + : 0, ), - const SizedBox(height: 16), - Text( - 'No ${selectedFilter.toLowerCase()} transactions found', - style: TextStyle( - color: AppColor.textSecondary, - fontSize: 16, - ), + child: OrderStatusTile( + label: option, + isSelected: option == selectedFilter, + onSelected: (isSelected) { + if (isSelected) { + setState(() { + selectedFilter = option; + }); + if (option.toLowerCase() == 'all') { + context.read().add( + OrderLoaderEvent.statusChanged( + '', + ), + ); + } else { + context.read().add( + OrderLoaderEvent.statusChanged( + option.toLowerCase(), + ), + ); + } + } + }, ), - ], - ), - ) - : Column( - children: filteredTransactions.map(( - transaction, - ) { - return OrderTile( - transaction: transaction, - onTap: () {}, ); }).toList(), ), - ], + ), + ], + ), + ), ), ), - ), - ]), - ), - ), - ], + + // Content + SliverPadding( + padding: EdgeInsets.all(AppValue.padding), + sliver: SliverList( + delegate: SliverChildListDelegate([ + FadeTransition( + opacity: _fadeAnimation, + child: SlideTransition( + position: _slideAnimation, + child: Column( + children: [ + // Show filtered transaction count + if (selectedFilter != 'All') + Padding( + padding: const EdgeInsets.only(bottom: 16), + child: Row( + children: [ + Text( + '${state.orders.length} ${selectedFilter.toLowerCase()} order${state.orders.length != 1 ? 's' : ''}', + style: TextStyle( + color: AppColor.textSecondary, + fontSize: 14, + ), + ), + ], + ), + ), + + // Transaction List + state.orders.isEmpty + ? EmptyWidget( + title: 'Order', + message: + 'No ${selectedFilter.toLowerCase()} orders found', + ) + : ListView.builder( + itemCount: state.orders.length, + shrinkWrap: true, + physics: + const NeverScrollableScrollPhysics(), + padding: EdgeInsets.zero, + itemBuilder: (context, index) { + return OrderTile( + onTap: () {}, + order: state.orders[index], + ); + }, + ), + ], + ), + ), + ), + ]), + ), + ), + ], + ), + ); + }, + ), ), ); } diff --git a/lib/presentation/pages/order/widgets/order_tile.dart b/lib/presentation/pages/order/widgets/order_tile.dart index f4e9a6a..f724262 100644 --- a/lib/presentation/pages/order/widgets/order_tile.dart +++ b/lib/presentation/pages/order/widgets/order_tile.dart @@ -2,41 +2,17 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import '../../../../common/theme/theme.dart'; - -// Model untuk Transaction -class Transaction { - final String id; - final String customerName; - final DateTime date; - final double totalAmount; - final int itemCount; - final String paymentMethod; - final TransactionStatus status; - final String? receiptNumber; - - Transaction({ - required this.id, - required this.customerName, - required this.date, - required this.totalAmount, - required this.itemCount, - required this.paymentMethod, - required this.status, - this.receiptNumber, - }); -} - -enum TransactionStatus { completed, pending, cancelled, refunded } +import '../../../../domain/order/order.dart'; class OrderTile extends StatelessWidget { - final Transaction transaction; + final Order order; final VoidCallback? onTap; final VoidCallback? onPrint; final VoidCallback? onRefund; const OrderTile({ super.key, - required this.transaction, + required this.order, this.onTap, this.onPrint, this.onRefund, @@ -73,8 +49,8 @@ class OrderTile extends StatelessWidget { _buildHeaderRow(), const SizedBox(height: 12), - // Transaction Info - _buildTransactionInfo(), + // Order Info + _buildOrderInfo(), const SizedBox(height: 16), // Amount Section @@ -99,7 +75,9 @@ class OrderTile extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - transaction.receiptNumber ?? 'TXN-${transaction.id}', + order.orderNumber.isNotEmpty + ? order.orderNumber + : 'ORD-${order.id}', style: const TextStyle( fontSize: 16, fontWeight: FontWeight.bold, @@ -108,7 +86,7 @@ class OrderTile extends StatelessWidget { ), const SizedBox(height: 2), Text( - DateFormat('dd MMM yyyy, HH:mm').format(transaction.date), + _formatDate(order.createdAt), style: const TextStyle( fontSize: 12, color: AppColor.textSecondary, @@ -126,27 +104,38 @@ class OrderTile extends StatelessWidget { String statusText; IconData statusIcon; - switch (transaction.status) { - case TransactionStatus.completed: - statusColor = AppColor.success; - statusText = 'Completed'; - statusIcon = Icons.check_circle; - break; - case TransactionStatus.pending: - statusColor = AppColor.warning; - statusText = 'Pending'; - statusIcon = Icons.schedule; - break; - case TransactionStatus.cancelled: - statusColor = AppColor.error; - statusText = 'Cancelled'; - statusIcon = Icons.cancel; - break; - case TransactionStatus.refunded: - statusColor = AppColor.info; - statusText = 'Refunded'; - statusIcon = Icons.undo; - break; + // Check isVoid and isRefund first for display + if (order.isVoid) { + statusColor = AppColor.error; + statusText = 'Void'; + statusIcon = Icons.block; + } else if (order.isRefund) { + statusColor = AppColor.info; + statusText = 'Refunded'; + statusIcon = Icons.undo; + } else { + // Handle status values (only pending and completed) + switch (order.status.toLowerCase()) { + case 'completed': + case 'paid': + case 'finished': + statusColor = AppColor.success; + statusText = 'Completed'; + statusIcon = Icons.check_circle; + break; + case 'pending': + case 'waiting': + case 'processing': + statusColor = AppColor.warning; + statusText = 'Pending'; + statusIcon = Icons.schedule; + break; + default: + statusColor = AppColor.textSecondary; + statusText = order.status; + statusIcon = Icons.info; + break; + } } return Container( @@ -174,7 +163,7 @@ class OrderTile extends StatelessWidget { ); } - Widget _buildTransactionInfo() { + Widget _buildOrderInfo() { return Row( children: [ Expanded( @@ -184,11 +173,11 @@ class OrderTile extends StatelessWidget { children: [ Row( children: [ - Icon(Icons.person_outline, size: 16, color: AppColor.primary), + Icon(_getOrderInfoIcon(), size: 16, color: AppColor.primary), const SizedBox(width: 6), Expanded( child: Text( - transaction.customerName, + _getOrderInfoText(), style: const TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -209,7 +198,7 @@ class OrderTile extends StatelessWidget { ), const SizedBox(width: 6), Text( - '${transaction.itemCount} items', + '${order.orderItems.length} items', style: const TextStyle( fontSize: 13, color: AppColor.textSecondary, @@ -230,13 +219,13 @@ class OrderTile extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Icon( - _getPaymentIcon(transaction.paymentMethod), + _getOrderTypeIcon(order.orderType), size: 16, color: AppColor.primary, ), const SizedBox(width: 6), Text( - transaction.paymentMethod, + order.orderType.isNotEmpty ? order.orderType : 'Dine In', style: const TextStyle( fontSize: 12, fontWeight: FontWeight.w500, @@ -285,13 +274,24 @@ class OrderTile extends StatelessWidget { ), const SizedBox(height: 4), Text( - 'Rp ${NumberFormat('#,###').format(transaction.totalAmount)}', + 'Rp ${NumberFormat('#,###').format(order.totalAmount)}', style: const TextStyle( fontSize: 24, fontWeight: FontWeight.bold, color: AppColor.textWhite, ), ), + if (order.remainingAmount > 0) ...[ + const SizedBox(height: 4), + Text( + 'Remaining: Rp ${NumberFormat('#,###').format(order.remainingAmount)}', + style: const TextStyle( + fontSize: 12, + color: AppColor.textWhite, + fontWeight: FontWeight.w400, + ), + ), + ], ], ), Container( @@ -300,8 +300,8 @@ class OrderTile extends StatelessWidget { color: AppColor.backgroundLight.withOpacity(0.2), shape: BoxShape.circle, ), - child: const Icon( - Icons.attach_money, + child: Icon( + _getPaymentStatusIcon(order.paymentStatus), color: AppColor.textWhite, size: 24, ), @@ -312,19 +312,32 @@ class OrderTile extends StatelessWidget { } Widget _buildFooterActions() { + // Don't show anything if order is void or refunded + if (order.isVoid || order.isRefund) { + return const SizedBox.shrink(); + } + return Row( children: [ Expanded( - child: Text( - 'ID: ${transaction.id}', - style: const TextStyle( - fontSize: 11, - color: AppColor.textLight, - fontWeight: FontWeight.w500, - ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (order.payments.isNotEmpty) ...[ + const SizedBox(height: 2), + Text( + 'Payment: ${_getPaymentMethods()}', + style: const TextStyle( + fontSize: 11, + color: AppColor.textLight, + fontWeight: FontWeight.w400, + ), + ), + ], + ], ), ), - if (transaction.status == TransactionStatus.completed) ...[ + if (order.status.toLowerCase() == 'completed') ...[ _buildActionButton( icon: Icons.print, label: 'Print', @@ -377,25 +390,90 @@ class OrderTile extends StatelessWidget { ); } - IconData _getPaymentIcon(String paymentMethod) { - switch (paymentMethod.toLowerCase()) { - case 'cash': - return Icons.payments; - case 'card': - case 'credit card': - case 'debit card': - return Icons.credit_card; - case 'qris': - case 'qr code': - return Icons.qr_code; - case 'transfer': - case 'bank transfer': - return Icons.account_balance; - case 'e-wallet': - case 'digital wallet': - return Icons.account_balance_wallet; + IconData _getOrderInfoIcon() { + switch (order.orderType.toLowerCase()) { + case 'dine in': + case 'dine_in': + return Icons.table_restaurant_outlined; + case 'takeaway': + case 'take_away': + case 'pickup': + return Icons.person_outline; + case 'delivery': + return Icons.location_on_outlined; default: - return Icons.payment; + return Icons.receipt_outlined; + } + } + + String _getOrderInfoText() { + switch (order.orderType.toLowerCase()) { + case 'dine in': + case 'dine_in': + return 'Table ${order.tableNumber.isNotEmpty ? order.tableNumber : 'N/A'}'; + case 'takeaway': + case 'take_away': + case 'pickup': + return 'Pickup Order'; + case 'delivery': + return 'Delivery Order'; + default: + return order.tableNumber.isNotEmpty + ? 'Table ${order.tableNumber}' + : 'Order ${order.orderNumber}'; + } + } + + IconData _getOrderTypeIcon(String orderType) { + switch (orderType.toLowerCase()) { + case 'dine in': + case 'dine_in': + return Icons.restaurant; + case 'takeaway': + case 'take_away': + case 'pickup': + return Icons.shopping_bag; + case 'delivery': + return Icons.delivery_dining; + default: + return Icons.restaurant_menu; + } + } + + IconData _getPaymentStatusIcon(String paymentStatus) { + switch (paymentStatus.toLowerCase()) { + case 'paid': + case 'completed': + return Icons.check_circle; + case 'pending': + case 'partial': + return Icons.schedule; + case 'failed': + case 'cancelled': + return Icons.error; + default: + return Icons.attach_money; + } + } + + String _getPaymentMethods() { + if (order.payments.isEmpty) return 'N/A'; + + // Get unique payment methods from payments + final methods = order.payments + .map((payment) => payment.paymentMethodName) + .toSet() + .join(', '); + + return methods.isEmpty ? 'N/A' : methods; + } + + String _formatDate(String dateString) { + try { + final date = DateTime.parse(dateString); + return DateFormat('dd MMM yyyy, HH:mm').format(date); + } catch (e) { + return dateString; } } }