diff --git a/lib/application/sales/sales_loader/sales_loader_bloc.dart b/lib/application/sales/sales_loader/sales_loader_bloc.dart new file mode 100644 index 0000000..453002b --- /dev/null +++ b/lib/application/sales/sales_loader/sales_loader_bloc.dart @@ -0,0 +1,39 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/analytic/analytic.dart'; +import '../../../domain/analytic/repositories/i_analytic_repository.dart'; + +part 'sales_loader_event.dart'; +part 'sales_loader_state.dart'; +part 'sales_loader_bloc.freezed.dart'; + +@injectable +class SalesLoaderBloc extends Bloc { + final IAnalyticRepository _analyticRepository; + SalesLoaderBloc(this._analyticRepository) + : super(SalesLoaderState.initial()) { + on(_onSalesLoaderEvent); + } + + Future _onSalesLoaderEvent( + SalesLoaderEvent event, + Emitter emit, + ) async { + emit(state.copyWith(isFetching: true, failureOptionSales: none())); + + final result = await _analyticRepository.getSales( + dateFrom: DateTime.now().subtract(const Duration(days: 30)), + dateTo: DateTime.now(), + ); + + var data = result.fold( + (f) => state.copyWith(failureOptionSales: optionOf(f)), + (sales) => state.copyWith(sales: sales), + ); + + emit(data.copyWith(isFetching: false)); + } +} diff --git a/lib/application/sales/sales_loader/sales_loader_bloc.freezed.dart b/lib/application/sales/sales_loader/sales_loader_bloc.freezed.dart new file mode 100644 index 0000000..0f7b470 --- /dev/null +++ b/lib/application/sales/sales_loader/sales_loader_bloc.freezed.dart @@ -0,0 +1,376 @@ +// 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 'sales_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 _$SalesLoaderEvent { + @optionalTypeArgs + TResult when({ + required TResult Function() fectched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? fectched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? fectched, + required TResult orElse(), + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(_Fectched value) fectched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_Fectched value)? fectched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_Fectched value)? fectched, + required TResult orElse(), + }) => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SalesLoaderEventCopyWith<$Res> { + factory $SalesLoaderEventCopyWith( + SalesLoaderEvent value, + $Res Function(SalesLoaderEvent) then, + ) = _$SalesLoaderEventCopyWithImpl<$Res, SalesLoaderEvent>; +} + +/// @nodoc +class _$SalesLoaderEventCopyWithImpl<$Res, $Val extends SalesLoaderEvent> + implements $SalesLoaderEventCopyWith<$Res> { + _$SalesLoaderEventCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of SalesLoaderEvent + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$FectchedImplCopyWith<$Res> { + factory _$$FectchedImplCopyWith( + _$FectchedImpl value, + $Res Function(_$FectchedImpl) then, + ) = __$$FectchedImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$FectchedImplCopyWithImpl<$Res> + extends _$SalesLoaderEventCopyWithImpl<$Res, _$FectchedImpl> + implements _$$FectchedImplCopyWith<$Res> { + __$$FectchedImplCopyWithImpl( + _$FectchedImpl _value, + $Res Function(_$FectchedImpl) _then, + ) : super(_value, _then); + + /// Create a copy of SalesLoaderEvent + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$FectchedImpl implements _Fectched { + const _$FectchedImpl(); + + @override + String toString() { + return 'SalesLoaderEvent.fectched()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$FectchedImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() fectched, + }) { + return fectched(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? fectched, + }) { + return fectched?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? fectched, + required TResult orElse(), + }) { + if (fectched != null) { + return fectched(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_Fectched value) fectched, + }) { + return fectched(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_Fectched value)? fectched, + }) { + return fectched?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_Fectched value)? fectched, + required TResult orElse(), + }) { + if (fectched != null) { + return fectched(this); + } + return orElse(); + } +} + +abstract class _Fectched implements SalesLoaderEvent { + const factory _Fectched() = _$FectchedImpl; +} + +/// @nodoc +mixin _$SalesLoaderState { + SalesAnalytic get sales => throw _privateConstructorUsedError; + Option get failureOptionSales => + throw _privateConstructorUsedError; + bool get isFetching => throw _privateConstructorUsedError; + + /// Create a copy of SalesLoaderState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $SalesLoaderStateCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SalesLoaderStateCopyWith<$Res> { + factory $SalesLoaderStateCopyWith( + SalesLoaderState value, + $Res Function(SalesLoaderState) then, + ) = _$SalesLoaderStateCopyWithImpl<$Res, SalesLoaderState>; + @useResult + $Res call({ + SalesAnalytic sales, + Option failureOptionSales, + bool isFetching, + }); + + $SalesAnalyticCopyWith<$Res> get sales; +} + +/// @nodoc +class _$SalesLoaderStateCopyWithImpl<$Res, $Val extends SalesLoaderState> + implements $SalesLoaderStateCopyWith<$Res> { + _$SalesLoaderStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of SalesLoaderState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? sales = null, + Object? failureOptionSales = null, + Object? isFetching = null, + }) { + return _then( + _value.copyWith( + sales: null == sales + ? _value.sales + : sales // ignore: cast_nullable_to_non_nullable + as SalesAnalytic, + failureOptionSales: null == failureOptionSales + ? _value.failureOptionSales + : failureOptionSales // ignore: cast_nullable_to_non_nullable + as Option, + isFetching: null == isFetching + ? _value.isFetching + : isFetching // ignore: cast_nullable_to_non_nullable + as bool, + ) + as $Val, + ); + } + + /// Create a copy of SalesLoaderState + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $SalesAnalyticCopyWith<$Res> get sales { + return $SalesAnalyticCopyWith<$Res>(_value.sales, (value) { + return _then(_value.copyWith(sales: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$SalesLoaderStateImplCopyWith<$Res> + implements $SalesLoaderStateCopyWith<$Res> { + factory _$$SalesLoaderStateImplCopyWith( + _$SalesLoaderStateImpl value, + $Res Function(_$SalesLoaderStateImpl) then, + ) = __$$SalesLoaderStateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + SalesAnalytic sales, + Option failureOptionSales, + bool isFetching, + }); + + @override + $SalesAnalyticCopyWith<$Res> get sales; +} + +/// @nodoc +class __$$SalesLoaderStateImplCopyWithImpl<$Res> + extends _$SalesLoaderStateCopyWithImpl<$Res, _$SalesLoaderStateImpl> + implements _$$SalesLoaderStateImplCopyWith<$Res> { + __$$SalesLoaderStateImplCopyWithImpl( + _$SalesLoaderStateImpl _value, + $Res Function(_$SalesLoaderStateImpl) _then, + ) : super(_value, _then); + + /// Create a copy of SalesLoaderState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? sales = null, + Object? failureOptionSales = null, + Object? isFetching = null, + }) { + return _then( + _$SalesLoaderStateImpl( + sales: null == sales + ? _value.sales + : sales // ignore: cast_nullable_to_non_nullable + as SalesAnalytic, + failureOptionSales: null == failureOptionSales + ? _value.failureOptionSales + : failureOptionSales // ignore: cast_nullable_to_non_nullable + as Option, + isFetching: null == isFetching + ? _value.isFetching + : isFetching // ignore: cast_nullable_to_non_nullable + as bool, + ), + ); + } +} + +/// @nodoc + +class _$SalesLoaderStateImpl implements _SalesLoaderState { + const _$SalesLoaderStateImpl({ + required this.sales, + required this.failureOptionSales, + this.isFetching = false, + }); + + @override + final SalesAnalytic sales; + @override + final Option failureOptionSales; + @override + @JsonKey() + final bool isFetching; + + @override + String toString() { + return 'SalesLoaderState(sales: $sales, failureOptionSales: $failureOptionSales, isFetching: $isFetching)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SalesLoaderStateImpl && + (identical(other.sales, sales) || other.sales == sales) && + (identical(other.failureOptionSales, failureOptionSales) || + other.failureOptionSales == failureOptionSales) && + (identical(other.isFetching, isFetching) || + other.isFetching == isFetching)); + } + + @override + int get hashCode => + Object.hash(runtimeType, sales, failureOptionSales, isFetching); + + /// Create a copy of SalesLoaderState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SalesLoaderStateImplCopyWith<_$SalesLoaderStateImpl> get copyWith => + __$$SalesLoaderStateImplCopyWithImpl<_$SalesLoaderStateImpl>( + this, + _$identity, + ); +} + +abstract class _SalesLoaderState implements SalesLoaderState { + const factory _SalesLoaderState({ + required final SalesAnalytic sales, + required final Option failureOptionSales, + final bool isFetching, + }) = _$SalesLoaderStateImpl; + + @override + SalesAnalytic get sales; + @override + Option get failureOptionSales; + @override + bool get isFetching; + + /// Create a copy of SalesLoaderState + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SalesLoaderStateImplCopyWith<_$SalesLoaderStateImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/application/sales/sales_loader/sales_loader_event.dart b/lib/application/sales/sales_loader/sales_loader_event.dart new file mode 100644 index 0000000..4838c2e --- /dev/null +++ b/lib/application/sales/sales_loader/sales_loader_event.dart @@ -0,0 +1,6 @@ +part of 'sales_loader_bloc.dart'; + +@freezed +class SalesLoaderEvent with _$SalesLoaderEvent { + const factory SalesLoaderEvent.fectched() = _Fectched; +} diff --git a/lib/application/sales/sales_loader/sales_loader_state.dart b/lib/application/sales/sales_loader/sales_loader_state.dart new file mode 100644 index 0000000..79cea6f --- /dev/null +++ b/lib/application/sales/sales_loader/sales_loader_state.dart @@ -0,0 +1,15 @@ +part of 'sales_loader_bloc.dart'; + +@freezed +class SalesLoaderState with _$SalesLoaderState { + const factory SalesLoaderState({ + required SalesAnalytic sales, + required Option failureOptionSales, + @Default(false) bool isFetching, + }) = _SalesLoaderState; + + factory SalesLoaderState.initial() => SalesLoaderState( + sales: SalesAnalytic.empty(), + failureOptionSales: none(), + ); +} diff --git a/lib/common/url/api_path.dart b/lib/common/url/api_path.dart index e3ef4ea..114fcb1 100644 --- a/lib/common/url/api_path.dart +++ b/lib/common/url/api_path.dart @@ -2,4 +2,7 @@ class ApiPath { // Auth static const String login = '/api/v1/auth/login'; static const String logout = '/api/v1/auth/logout'; + + // Analytic + static const String salesAnalytic = '/api/v1/analytics/sales'; } diff --git a/lib/domain/analytic/analytic.dart b/lib/domain/analytic/analytic.dart new file mode 100644 index 0000000..8190576 --- /dev/null +++ b/lib/domain/analytic/analytic.dart @@ -0,0 +1,8 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +import '../../common/api/api_failure.dart'; + +part 'analytic.freezed.dart'; + +part 'entities/sales_analytic_entity.dart'; +part 'failures/analytic_failure.dart'; diff --git a/lib/domain/analytic/analytic.freezed.dart b/lib/domain/analytic/analytic.freezed.dart new file mode 100644 index 0000000..c2a75be --- /dev/null +++ b/lib/domain/analytic/analytic.freezed.dart @@ -0,0 +1,1510 @@ +// 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 'analytic.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 _$SalesAnalytic { + String get organizationId => throw _privateConstructorUsedError; + String get outletId => throw _privateConstructorUsedError; + DateTime get dateFrom => throw _privateConstructorUsedError; + DateTime get dateTo => throw _privateConstructorUsedError; + String get groupBy => throw _privateConstructorUsedError; + SalesAnalyticSummary get summary => throw _privateConstructorUsedError; + List get data => throw _privateConstructorUsedError; + + /// Create a copy of SalesAnalytic + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $SalesAnalyticCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SalesAnalyticCopyWith<$Res> { + factory $SalesAnalyticCopyWith( + SalesAnalytic value, + $Res Function(SalesAnalytic) then, + ) = _$SalesAnalyticCopyWithImpl<$Res, SalesAnalytic>; + @useResult + $Res call({ + String organizationId, + String outletId, + DateTime dateFrom, + DateTime dateTo, + String groupBy, + SalesAnalyticSummary summary, + List data, + }); + + $SalesAnalyticSummaryCopyWith<$Res> get summary; +} + +/// @nodoc +class _$SalesAnalyticCopyWithImpl<$Res, $Val extends SalesAnalytic> + implements $SalesAnalyticCopyWith<$Res> { + _$SalesAnalyticCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of SalesAnalytic + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? organizationId = null, + Object? outletId = null, + Object? dateFrom = null, + Object? dateTo = null, + Object? groupBy = null, + Object? summary = null, + Object? data = null, + }) { + return _then( + _value.copyWith( + organizationId: null == organizationId + ? _value.organizationId + : organizationId // ignore: cast_nullable_to_non_nullable + as String, + outletId: null == outletId + ? _value.outletId + : outletId // ignore: cast_nullable_to_non_nullable + as String, + dateFrom: null == dateFrom + ? _value.dateFrom + : dateFrom // ignore: cast_nullable_to_non_nullable + as DateTime, + dateTo: null == dateTo + ? _value.dateTo + : dateTo // ignore: cast_nullable_to_non_nullable + as DateTime, + groupBy: null == groupBy + ? _value.groupBy + : groupBy // ignore: cast_nullable_to_non_nullable + as String, + summary: null == summary + ? _value.summary + : summary // ignore: cast_nullable_to_non_nullable + as SalesAnalyticSummary, + data: null == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as List, + ) + as $Val, + ); + } + + /// Create a copy of SalesAnalytic + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $SalesAnalyticSummaryCopyWith<$Res> get summary { + return $SalesAnalyticSummaryCopyWith<$Res>(_value.summary, (value) { + return _then(_value.copyWith(summary: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$SalesAnalyticImplCopyWith<$Res> + implements $SalesAnalyticCopyWith<$Res> { + factory _$$SalesAnalyticImplCopyWith( + _$SalesAnalyticImpl value, + $Res Function(_$SalesAnalyticImpl) then, + ) = __$$SalesAnalyticImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String organizationId, + String outletId, + DateTime dateFrom, + DateTime dateTo, + String groupBy, + SalesAnalyticSummary summary, + List data, + }); + + @override + $SalesAnalyticSummaryCopyWith<$Res> get summary; +} + +/// @nodoc +class __$$SalesAnalyticImplCopyWithImpl<$Res> + extends _$SalesAnalyticCopyWithImpl<$Res, _$SalesAnalyticImpl> + implements _$$SalesAnalyticImplCopyWith<$Res> { + __$$SalesAnalyticImplCopyWithImpl( + _$SalesAnalyticImpl _value, + $Res Function(_$SalesAnalyticImpl) _then, + ) : super(_value, _then); + + /// Create a copy of SalesAnalytic + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? organizationId = null, + Object? outletId = null, + Object? dateFrom = null, + Object? dateTo = null, + Object? groupBy = null, + Object? summary = null, + Object? data = null, + }) { + return _then( + _$SalesAnalyticImpl( + organizationId: null == organizationId + ? _value.organizationId + : organizationId // ignore: cast_nullable_to_non_nullable + as String, + outletId: null == outletId + ? _value.outletId + : outletId // ignore: cast_nullable_to_non_nullable + as String, + dateFrom: null == dateFrom + ? _value.dateFrom + : dateFrom // ignore: cast_nullable_to_non_nullable + as DateTime, + dateTo: null == dateTo + ? _value.dateTo + : dateTo // ignore: cast_nullable_to_non_nullable + as DateTime, + groupBy: null == groupBy + ? _value.groupBy + : groupBy // ignore: cast_nullable_to_non_nullable + as String, + summary: null == summary + ? _value.summary + : summary // ignore: cast_nullable_to_non_nullable + as SalesAnalyticSummary, + data: null == data + ? _value._data + : data // ignore: cast_nullable_to_non_nullable + as List, + ), + ); + } +} + +/// @nodoc + +class _$SalesAnalyticImpl implements _SalesAnalytic { + const _$SalesAnalyticImpl({ + required this.organizationId, + required this.outletId, + required this.dateFrom, + required this.dateTo, + required this.groupBy, + required this.summary, + required final List data, + }) : _data = data; + + @override + final String organizationId; + @override + final String outletId; + @override + final DateTime dateFrom; + @override + final DateTime dateTo; + @override + final String groupBy; + @override + final SalesAnalyticSummary summary; + final List _data; + @override + List get data { + if (_data is EqualUnmodifiableListView) return _data; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_data); + } + + @override + String toString() { + return 'SalesAnalytic(organizationId: $organizationId, outletId: $outletId, dateFrom: $dateFrom, dateTo: $dateTo, groupBy: $groupBy, summary: $summary, data: $data)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SalesAnalyticImpl && + (identical(other.organizationId, organizationId) || + other.organizationId == organizationId) && + (identical(other.outletId, outletId) || + other.outletId == outletId) && + (identical(other.dateFrom, dateFrom) || + other.dateFrom == dateFrom) && + (identical(other.dateTo, dateTo) || other.dateTo == dateTo) && + (identical(other.groupBy, groupBy) || other.groupBy == groupBy) && + (identical(other.summary, summary) || other.summary == summary) && + const DeepCollectionEquality().equals(other._data, _data)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + organizationId, + outletId, + dateFrom, + dateTo, + groupBy, + summary, + const DeepCollectionEquality().hash(_data), + ); + + /// Create a copy of SalesAnalytic + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SalesAnalyticImplCopyWith<_$SalesAnalyticImpl> get copyWith => + __$$SalesAnalyticImplCopyWithImpl<_$SalesAnalyticImpl>(this, _$identity); +} + +abstract class _SalesAnalytic implements SalesAnalytic { + const factory _SalesAnalytic({ + required final String organizationId, + required final String outletId, + required final DateTime dateFrom, + required final DateTime dateTo, + required final String groupBy, + required final SalesAnalyticSummary summary, + required final List data, + }) = _$SalesAnalyticImpl; + + @override + String get organizationId; + @override + String get outletId; + @override + DateTime get dateFrom; + @override + DateTime get dateTo; + @override + String get groupBy; + @override + SalesAnalyticSummary get summary; + @override + List get data; + + /// Create a copy of SalesAnalytic + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SalesAnalyticImplCopyWith<_$SalesAnalyticImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$SalesAnalyticSummary { + int get totalSales => throw _privateConstructorUsedError; + int get totalOrders => throw _privateConstructorUsedError; + int get totalItems => throw _privateConstructorUsedError; + double get averageOrderValue => throw _privateConstructorUsedError; + int get totalTax => throw _privateConstructorUsedError; + int get totalDiscount => throw _privateConstructorUsedError; + int get netSales => throw _privateConstructorUsedError; + + /// Create a copy of SalesAnalyticSummary + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $SalesAnalyticSummaryCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SalesAnalyticSummaryCopyWith<$Res> { + factory $SalesAnalyticSummaryCopyWith( + SalesAnalyticSummary value, + $Res Function(SalesAnalyticSummary) then, + ) = _$SalesAnalyticSummaryCopyWithImpl<$Res, SalesAnalyticSummary>; + @useResult + $Res call({ + int totalSales, + int totalOrders, + int totalItems, + double averageOrderValue, + int totalTax, + int totalDiscount, + int netSales, + }); +} + +/// @nodoc +class _$SalesAnalyticSummaryCopyWithImpl< + $Res, + $Val extends SalesAnalyticSummary +> + implements $SalesAnalyticSummaryCopyWith<$Res> { + _$SalesAnalyticSummaryCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of SalesAnalyticSummary + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? totalSales = null, + Object? totalOrders = null, + Object? totalItems = null, + Object? averageOrderValue = null, + Object? totalTax = null, + Object? totalDiscount = null, + Object? netSales = null, + }) { + return _then( + _value.copyWith( + totalSales: null == totalSales + ? _value.totalSales + : totalSales // ignore: cast_nullable_to_non_nullable + as int, + totalOrders: null == totalOrders + ? _value.totalOrders + : totalOrders // ignore: cast_nullable_to_non_nullable + as int, + totalItems: null == totalItems + ? _value.totalItems + : totalItems // ignore: cast_nullable_to_non_nullable + as int, + averageOrderValue: null == averageOrderValue + ? _value.averageOrderValue + : averageOrderValue // ignore: cast_nullable_to_non_nullable + as double, + totalTax: null == totalTax + ? _value.totalTax + : totalTax // ignore: cast_nullable_to_non_nullable + as int, + totalDiscount: null == totalDiscount + ? _value.totalDiscount + : totalDiscount // ignore: cast_nullable_to_non_nullable + as int, + netSales: null == netSales + ? _value.netSales + : netSales // ignore: cast_nullable_to_non_nullable + as int, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$SalesAnalyticSummaryImplCopyWith<$Res> + implements $SalesAnalyticSummaryCopyWith<$Res> { + factory _$$SalesAnalyticSummaryImplCopyWith( + _$SalesAnalyticSummaryImpl value, + $Res Function(_$SalesAnalyticSummaryImpl) then, + ) = __$$SalesAnalyticSummaryImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + int totalSales, + int totalOrders, + int totalItems, + double averageOrderValue, + int totalTax, + int totalDiscount, + int netSales, + }); +} + +/// @nodoc +class __$$SalesAnalyticSummaryImplCopyWithImpl<$Res> + extends _$SalesAnalyticSummaryCopyWithImpl<$Res, _$SalesAnalyticSummaryImpl> + implements _$$SalesAnalyticSummaryImplCopyWith<$Res> { + __$$SalesAnalyticSummaryImplCopyWithImpl( + _$SalesAnalyticSummaryImpl _value, + $Res Function(_$SalesAnalyticSummaryImpl) _then, + ) : super(_value, _then); + + /// Create a copy of SalesAnalyticSummary + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? totalSales = null, + Object? totalOrders = null, + Object? totalItems = null, + Object? averageOrderValue = null, + Object? totalTax = null, + Object? totalDiscount = null, + Object? netSales = null, + }) { + return _then( + _$SalesAnalyticSummaryImpl( + totalSales: null == totalSales + ? _value.totalSales + : totalSales // ignore: cast_nullable_to_non_nullable + as int, + totalOrders: null == totalOrders + ? _value.totalOrders + : totalOrders // ignore: cast_nullable_to_non_nullable + as int, + totalItems: null == totalItems + ? _value.totalItems + : totalItems // ignore: cast_nullable_to_non_nullable + as int, + averageOrderValue: null == averageOrderValue + ? _value.averageOrderValue + : averageOrderValue // ignore: cast_nullable_to_non_nullable + as double, + totalTax: null == totalTax + ? _value.totalTax + : totalTax // ignore: cast_nullable_to_non_nullable + as int, + totalDiscount: null == totalDiscount + ? _value.totalDiscount + : totalDiscount // ignore: cast_nullable_to_non_nullable + as int, + netSales: null == netSales + ? _value.netSales + : netSales // ignore: cast_nullable_to_non_nullable + as int, + ), + ); + } +} + +/// @nodoc + +class _$SalesAnalyticSummaryImpl implements _SalesAnalyticSummary { + const _$SalesAnalyticSummaryImpl({ + required this.totalSales, + required this.totalOrders, + required this.totalItems, + required this.averageOrderValue, + required this.totalTax, + required this.totalDiscount, + required this.netSales, + }); + + @override + final int totalSales; + @override + final int totalOrders; + @override + final int totalItems; + @override + final double averageOrderValue; + @override + final int totalTax; + @override + final int totalDiscount; + @override + final int netSales; + + @override + String toString() { + return 'SalesAnalyticSummary(totalSales: $totalSales, totalOrders: $totalOrders, totalItems: $totalItems, averageOrderValue: $averageOrderValue, totalTax: $totalTax, totalDiscount: $totalDiscount, netSales: $netSales)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SalesAnalyticSummaryImpl && + (identical(other.totalSales, totalSales) || + other.totalSales == totalSales) && + (identical(other.totalOrders, totalOrders) || + other.totalOrders == totalOrders) && + (identical(other.totalItems, totalItems) || + other.totalItems == totalItems) && + (identical(other.averageOrderValue, averageOrderValue) || + other.averageOrderValue == averageOrderValue) && + (identical(other.totalTax, totalTax) || + other.totalTax == totalTax) && + (identical(other.totalDiscount, totalDiscount) || + other.totalDiscount == totalDiscount) && + (identical(other.netSales, netSales) || + other.netSales == netSales)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + totalSales, + totalOrders, + totalItems, + averageOrderValue, + totalTax, + totalDiscount, + netSales, + ); + + /// Create a copy of SalesAnalyticSummary + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SalesAnalyticSummaryImplCopyWith<_$SalesAnalyticSummaryImpl> + get copyWith => + __$$SalesAnalyticSummaryImplCopyWithImpl<_$SalesAnalyticSummaryImpl>( + this, + _$identity, + ); +} + +abstract class _SalesAnalyticSummary implements SalesAnalyticSummary { + const factory _SalesAnalyticSummary({ + required final int totalSales, + required final int totalOrders, + required final int totalItems, + required final double averageOrderValue, + required final int totalTax, + required final int totalDiscount, + required final int netSales, + }) = _$SalesAnalyticSummaryImpl; + + @override + int get totalSales; + @override + int get totalOrders; + @override + int get totalItems; + @override + double get averageOrderValue; + @override + int get totalTax; + @override + int get totalDiscount; + @override + int get netSales; + + /// Create a copy of SalesAnalyticSummary + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SalesAnalyticSummaryImplCopyWith<_$SalesAnalyticSummaryImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$SalesAnalyticData { + DateTime get date => throw _privateConstructorUsedError; + int get sales => throw _privateConstructorUsedError; + int get orders => throw _privateConstructorUsedError; + int get items => throw _privateConstructorUsedError; + int get tax => throw _privateConstructorUsedError; + int get discount => throw _privateConstructorUsedError; + int get netSales => throw _privateConstructorUsedError; + + /// Create a copy of SalesAnalyticData + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $SalesAnalyticDataCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SalesAnalyticDataCopyWith<$Res> { + factory $SalesAnalyticDataCopyWith( + SalesAnalyticData value, + $Res Function(SalesAnalyticData) then, + ) = _$SalesAnalyticDataCopyWithImpl<$Res, SalesAnalyticData>; + @useResult + $Res call({ + DateTime date, + int sales, + int orders, + int items, + int tax, + int discount, + int netSales, + }); +} + +/// @nodoc +class _$SalesAnalyticDataCopyWithImpl<$Res, $Val extends SalesAnalyticData> + implements $SalesAnalyticDataCopyWith<$Res> { + _$SalesAnalyticDataCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of SalesAnalyticData + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? date = null, + Object? sales = null, + Object? orders = null, + Object? items = null, + Object? tax = null, + Object? discount = null, + Object? netSales = null, + }) { + return _then( + _value.copyWith( + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as DateTime, + sales: null == sales + ? _value.sales + : sales // ignore: cast_nullable_to_non_nullable + as int, + orders: null == orders + ? _value.orders + : orders // ignore: cast_nullable_to_non_nullable + as int, + items: null == items + ? _value.items + : items // ignore: cast_nullable_to_non_nullable + as int, + tax: null == tax + ? _value.tax + : tax // ignore: cast_nullable_to_non_nullable + as int, + discount: null == discount + ? _value.discount + : discount // ignore: cast_nullable_to_non_nullable + as int, + netSales: null == netSales + ? _value.netSales + : netSales // ignore: cast_nullable_to_non_nullable + as int, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$SalesAnalyticDataImplCopyWith<$Res> + implements $SalesAnalyticDataCopyWith<$Res> { + factory _$$SalesAnalyticDataImplCopyWith( + _$SalesAnalyticDataImpl value, + $Res Function(_$SalesAnalyticDataImpl) then, + ) = __$$SalesAnalyticDataImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + DateTime date, + int sales, + int orders, + int items, + int tax, + int discount, + int netSales, + }); +} + +/// @nodoc +class __$$SalesAnalyticDataImplCopyWithImpl<$Res> + extends _$SalesAnalyticDataCopyWithImpl<$Res, _$SalesAnalyticDataImpl> + implements _$$SalesAnalyticDataImplCopyWith<$Res> { + __$$SalesAnalyticDataImplCopyWithImpl( + _$SalesAnalyticDataImpl _value, + $Res Function(_$SalesAnalyticDataImpl) _then, + ) : super(_value, _then); + + /// Create a copy of SalesAnalyticData + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? date = null, + Object? sales = null, + Object? orders = null, + Object? items = null, + Object? tax = null, + Object? discount = null, + Object? netSales = null, + }) { + return _then( + _$SalesAnalyticDataImpl( + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as DateTime, + sales: null == sales + ? _value.sales + : sales // ignore: cast_nullable_to_non_nullable + as int, + orders: null == orders + ? _value.orders + : orders // ignore: cast_nullable_to_non_nullable + as int, + items: null == items + ? _value.items + : items // ignore: cast_nullable_to_non_nullable + as int, + tax: null == tax + ? _value.tax + : tax // ignore: cast_nullable_to_non_nullable + as int, + discount: null == discount + ? _value.discount + : discount // ignore: cast_nullable_to_non_nullable + as int, + netSales: null == netSales + ? _value.netSales + : netSales // ignore: cast_nullable_to_non_nullable + as int, + ), + ); + } +} + +/// @nodoc + +class _$SalesAnalyticDataImpl implements _SalesAnalyticData { + const _$SalesAnalyticDataImpl({ + required this.date, + required this.sales, + required this.orders, + required this.items, + required this.tax, + required this.discount, + required this.netSales, + }); + + @override + final DateTime date; + @override + final int sales; + @override + final int orders; + @override + final int items; + @override + final int tax; + @override + final int discount; + @override + final int netSales; + + @override + String toString() { + return 'SalesAnalyticData(date: $date, sales: $sales, orders: $orders, items: $items, tax: $tax, discount: $discount, netSales: $netSales)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SalesAnalyticDataImpl && + (identical(other.date, date) || other.date == date) && + (identical(other.sales, sales) || other.sales == sales) && + (identical(other.orders, orders) || other.orders == orders) && + (identical(other.items, items) || other.items == items) && + (identical(other.tax, tax) || other.tax == tax) && + (identical(other.discount, discount) || + other.discount == discount) && + (identical(other.netSales, netSales) || + other.netSales == netSales)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + date, + sales, + orders, + items, + tax, + discount, + netSales, + ); + + /// Create a copy of SalesAnalyticData + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SalesAnalyticDataImplCopyWith<_$SalesAnalyticDataImpl> get copyWith => + __$$SalesAnalyticDataImplCopyWithImpl<_$SalesAnalyticDataImpl>( + this, + _$identity, + ); +} + +abstract class _SalesAnalyticData implements SalesAnalyticData { + const factory _SalesAnalyticData({ + required final DateTime date, + required final int sales, + required final int orders, + required final int items, + required final int tax, + required final int discount, + required final int netSales, + }) = _$SalesAnalyticDataImpl; + + @override + DateTime get date; + @override + int get sales; + @override + int get orders; + @override + int get items; + @override + int get tax; + @override + int get discount; + @override + int get netSales; + + /// Create a copy of SalesAnalyticData + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SalesAnalyticDataImplCopyWith<_$SalesAnalyticDataImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$AnalyticFailure { + @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 $AnalyticFailureCopyWith<$Res> { + factory $AnalyticFailureCopyWith( + AnalyticFailure value, + $Res Function(AnalyticFailure) then, + ) = _$AnalyticFailureCopyWithImpl<$Res, AnalyticFailure>; +} + +/// @nodoc +class _$AnalyticFailureCopyWithImpl<$Res, $Val extends AnalyticFailure> + implements $AnalyticFailureCopyWith<$Res> { + _$AnalyticFailureCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of AnalyticFailure + /// 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 _$AnalyticFailureCopyWithImpl<$Res, _$ServerErrorImpl> + implements _$$ServerErrorImplCopyWith<$Res> { + __$$ServerErrorImplCopyWithImpl( + _$ServerErrorImpl _value, + $Res Function(_$ServerErrorImpl) _then, + ) : super(_value, _then); + + /// Create a copy of AnalyticFailure + /// 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 AnalyticFailure + /// 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 'AnalyticFailure.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 AnalyticFailure + /// 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 AnalyticFailure { + const factory _ServerError(final ApiFailure failure) = _$ServerErrorImpl; + + ApiFailure get failure; + + /// Create a copy of AnalyticFailure + /// 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 _$AnalyticFailureCopyWithImpl<$Res, _$UnexpectedErrorImpl> + implements _$$UnexpectedErrorImplCopyWith<$Res> { + __$$UnexpectedErrorImplCopyWithImpl( + _$UnexpectedErrorImpl _value, + $Res Function(_$UnexpectedErrorImpl) _then, + ) : super(_value, _then); + + /// Create a copy of AnalyticFailure + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$UnexpectedErrorImpl implements _UnexpectedError { + const _$UnexpectedErrorImpl(); + + @override + String toString() { + return 'AnalyticFailure.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 AnalyticFailure { + const factory _UnexpectedError() = _$UnexpectedErrorImpl; +} + +/// @nodoc +abstract class _$$EmptyImplCopyWith<$Res> { + factory _$$EmptyImplCopyWith( + _$EmptyImpl value, + $Res Function(_$EmptyImpl) then, + ) = __$$EmptyImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$EmptyImplCopyWithImpl<$Res> + extends _$AnalyticFailureCopyWithImpl<$Res, _$EmptyImpl> + implements _$$EmptyImplCopyWith<$Res> { + __$$EmptyImplCopyWithImpl( + _$EmptyImpl _value, + $Res Function(_$EmptyImpl) _then, + ) : super(_value, _then); + + /// Create a copy of AnalyticFailure + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$EmptyImpl implements _Empty { + const _$EmptyImpl(); + + @override + String toString() { + return 'AnalyticFailure.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 AnalyticFailure { + 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 _$AnalyticFailureCopyWithImpl<$Res, _$DynamicErrorMessageImpl> + implements _$$DynamicErrorMessageImplCopyWith<$Res> { + __$$DynamicErrorMessageImplCopyWithImpl( + _$DynamicErrorMessageImpl _value, + $Res Function(_$DynamicErrorMessageImpl) _then, + ) : super(_value, _then); + + /// Create a copy of AnalyticFailure + /// 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 'AnalyticFailure.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 AnalyticFailure + /// 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 AnalyticFailure { + const factory _DynamicErrorMessage(final String erroMessage) = + _$DynamicErrorMessageImpl; + + String get erroMessage; + + /// Create a copy of AnalyticFailure + /// 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/analytic/entities/sales_analytic_entity.dart b/lib/domain/analytic/entities/sales_analytic_entity.dart new file mode 100644 index 0000000..e53d57f --- /dev/null +++ b/lib/domain/analytic/entities/sales_analytic_entity.dart @@ -0,0 +1,70 @@ +part of '../analytic.dart'; + +@freezed +class SalesAnalytic with _$SalesAnalytic { + const factory SalesAnalytic({ + required String organizationId, + required String outletId, + required DateTime dateFrom, + required DateTime dateTo, + required String groupBy, + required SalesAnalyticSummary summary, + required List data, + }) = _SalesAnalytic; + + factory SalesAnalytic.empty() => SalesAnalytic( + organizationId: '', + outletId: '', + dateFrom: DateTime.fromMillisecondsSinceEpoch(0), + dateTo: DateTime.fromMillisecondsSinceEpoch(0), + groupBy: '', + summary: SalesAnalyticSummary.empty(), + data: [], + ); +} + +@freezed +class SalesAnalyticSummary with _$SalesAnalyticSummary { + const factory SalesAnalyticSummary({ + required int totalSales, + required int totalOrders, + required int totalItems, + required double averageOrderValue, + required int totalTax, + required int totalDiscount, + required int netSales, + }) = _SalesAnalyticSummary; + + factory SalesAnalyticSummary.empty() => const SalesAnalyticSummary( + totalSales: 0, + totalOrders: 0, + totalItems: 0, + averageOrderValue: 0, + totalTax: 0, + totalDiscount: 0, + netSales: 0, + ); +} + +@freezed +class SalesAnalyticData with _$SalesAnalyticData { + const factory SalesAnalyticData({ + required DateTime date, + required int sales, + required int orders, + required int items, + required int tax, + required int discount, + required int netSales, + }) = _SalesAnalyticData; + + factory SalesAnalyticData.empty() => SalesAnalyticData( + date: DateTime.fromMillisecondsSinceEpoch(0), + sales: 0, + orders: 0, + items: 0, + tax: 0, + discount: 0, + netSales: 0, + ); +} diff --git a/lib/domain/analytic/failures/analytic_failure.dart b/lib/domain/analytic/failures/analytic_failure.dart new file mode 100644 index 0000000..d0b1a54 --- /dev/null +++ b/lib/domain/analytic/failures/analytic_failure.dart @@ -0,0 +1,10 @@ +part of '../analytic.dart'; + +@freezed +sealed class AnalyticFailure with _$AnalyticFailure { + const factory AnalyticFailure.serverError(ApiFailure failure) = _ServerError; + const factory AnalyticFailure.unexpectedError() = _UnexpectedError; + const factory AnalyticFailure.empty() = _Empty; + const factory AnalyticFailure.dynamicErrorMessage(String erroMessage) = + _DynamicErrorMessage; +} diff --git a/lib/domain/analytic/repositories/i_analytic_repository.dart b/lib/domain/analytic/repositories/i_analytic_repository.dart new file mode 100644 index 0000000..6826dde --- /dev/null +++ b/lib/domain/analytic/repositories/i_analytic_repository.dart @@ -0,0 +1,10 @@ +import 'package:dartz/dartz.dart'; + +import '../analytic.dart'; + +abstract class IAnalyticRepository { + Future> getSales({ + required DateTime dateFrom, + required DateTime dateTo, + }); +} diff --git a/lib/infrastructure/analytic/analytic_dtos.dart b/lib/infrastructure/analytic/analytic_dtos.dart new file mode 100644 index 0000000..277bb65 --- /dev/null +++ b/lib/infrastructure/analytic/analytic_dtos.dart @@ -0,0 +1,8 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +import '../../domain/analytic/analytic.dart'; + +part 'analytic_dtos.freezed.dart'; +part 'analytic_dtos.g.dart'; + +part 'dto/sales_analytic_dto.dart'; diff --git a/lib/infrastructure/analytic/analytic_dtos.freezed.dart b/lib/infrastructure/analytic/analytic_dtos.freezed.dart new file mode 100644 index 0000000..d2f58d4 --- /dev/null +++ b/lib/infrastructure/analytic/analytic_dtos.freezed.dart @@ -0,0 +1,1019 @@ +// 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 'analytic_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', +); + +SalesAnalyticDto _$SalesAnalyticDtoFromJson(Map json) { + return _SalesAnalyticDto.fromJson(json); +} + +/// @nodoc +mixin _$SalesAnalyticDto { + @JsonKey(name: 'organization_id') + String? get organizationId => throw _privateConstructorUsedError; + @JsonKey(name: 'outlet_id') + String? get outletId => throw _privateConstructorUsedError; + @JsonKey(name: 'date_from') + DateTime? get dateFrom => throw _privateConstructorUsedError; + @JsonKey(name: 'date_to') + DateTime? get dateTo => throw _privateConstructorUsedError; + @JsonKey(name: 'group_by') + String? get groupBy => throw _privateConstructorUsedError; + @JsonKey(name: 'summary') + SalesAnalyticSummaryDto? get summary => throw _privateConstructorUsedError; + @JsonKey(name: 'data') + List? get data => throw _privateConstructorUsedError; + + /// Serializes this SalesAnalyticDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of SalesAnalyticDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $SalesAnalyticDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SalesAnalyticDtoCopyWith<$Res> { + factory $SalesAnalyticDtoCopyWith( + SalesAnalyticDto value, + $Res Function(SalesAnalyticDto) then, + ) = _$SalesAnalyticDtoCopyWithImpl<$Res, SalesAnalyticDto>; + @useResult + $Res call({ + @JsonKey(name: 'organization_id') String? organizationId, + @JsonKey(name: 'outlet_id') String? outletId, + @JsonKey(name: 'date_from') DateTime? dateFrom, + @JsonKey(name: 'date_to') DateTime? dateTo, + @JsonKey(name: 'group_by') String? groupBy, + @JsonKey(name: 'summary') SalesAnalyticSummaryDto? summary, + @JsonKey(name: 'data') List? data, + }); + + $SalesAnalyticSummaryDtoCopyWith<$Res>? get summary; +} + +/// @nodoc +class _$SalesAnalyticDtoCopyWithImpl<$Res, $Val extends SalesAnalyticDto> + implements $SalesAnalyticDtoCopyWith<$Res> { + _$SalesAnalyticDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of SalesAnalyticDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? organizationId = freezed, + Object? outletId = freezed, + Object? dateFrom = freezed, + Object? dateTo = freezed, + Object? groupBy = freezed, + Object? summary = freezed, + Object? data = freezed, + }) { + return _then( + _value.copyWith( + organizationId: freezed == organizationId + ? _value.organizationId + : organizationId // ignore: cast_nullable_to_non_nullable + as String?, + outletId: freezed == outletId + ? _value.outletId + : outletId // ignore: cast_nullable_to_non_nullable + as String?, + dateFrom: freezed == dateFrom + ? _value.dateFrom + : dateFrom // ignore: cast_nullable_to_non_nullable + as DateTime?, + dateTo: freezed == dateTo + ? _value.dateTo + : dateTo // ignore: cast_nullable_to_non_nullable + as DateTime?, + groupBy: freezed == groupBy + ? _value.groupBy + : groupBy // ignore: cast_nullable_to_non_nullable + as String?, + summary: freezed == summary + ? _value.summary + : summary // ignore: cast_nullable_to_non_nullable + as SalesAnalyticSummaryDto?, + data: freezed == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as List?, + ) + as $Val, + ); + } + + /// Create a copy of SalesAnalyticDto + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $SalesAnalyticSummaryDtoCopyWith<$Res>? get summary { + if (_value.summary == null) { + return null; + } + + return $SalesAnalyticSummaryDtoCopyWith<$Res>(_value.summary!, (value) { + return _then(_value.copyWith(summary: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$SalesAnalyticDtoImplCopyWith<$Res> + implements $SalesAnalyticDtoCopyWith<$Res> { + factory _$$SalesAnalyticDtoImplCopyWith( + _$SalesAnalyticDtoImpl value, + $Res Function(_$SalesAnalyticDtoImpl) then, + ) = __$$SalesAnalyticDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: 'organization_id') String? organizationId, + @JsonKey(name: 'outlet_id') String? outletId, + @JsonKey(name: 'date_from') DateTime? dateFrom, + @JsonKey(name: 'date_to') DateTime? dateTo, + @JsonKey(name: 'group_by') String? groupBy, + @JsonKey(name: 'summary') SalesAnalyticSummaryDto? summary, + @JsonKey(name: 'data') List? data, + }); + + @override + $SalesAnalyticSummaryDtoCopyWith<$Res>? get summary; +} + +/// @nodoc +class __$$SalesAnalyticDtoImplCopyWithImpl<$Res> + extends _$SalesAnalyticDtoCopyWithImpl<$Res, _$SalesAnalyticDtoImpl> + implements _$$SalesAnalyticDtoImplCopyWith<$Res> { + __$$SalesAnalyticDtoImplCopyWithImpl( + _$SalesAnalyticDtoImpl _value, + $Res Function(_$SalesAnalyticDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of SalesAnalyticDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? organizationId = freezed, + Object? outletId = freezed, + Object? dateFrom = freezed, + Object? dateTo = freezed, + Object? groupBy = freezed, + Object? summary = freezed, + Object? data = freezed, + }) { + return _then( + _$SalesAnalyticDtoImpl( + organizationId: freezed == organizationId + ? _value.organizationId + : organizationId // ignore: cast_nullable_to_non_nullable + as String?, + outletId: freezed == outletId + ? _value.outletId + : outletId // ignore: cast_nullable_to_non_nullable + as String?, + dateFrom: freezed == dateFrom + ? _value.dateFrom + : dateFrom // ignore: cast_nullable_to_non_nullable + as DateTime?, + dateTo: freezed == dateTo + ? _value.dateTo + : dateTo // ignore: cast_nullable_to_non_nullable + as DateTime?, + groupBy: freezed == groupBy + ? _value.groupBy + : groupBy // ignore: cast_nullable_to_non_nullable + as String?, + summary: freezed == summary + ? _value.summary + : summary // ignore: cast_nullable_to_non_nullable + as SalesAnalyticSummaryDto?, + data: freezed == data + ? _value._data + : data // ignore: cast_nullable_to_non_nullable + as List?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$SalesAnalyticDtoImpl extends _SalesAnalyticDto { + const _$SalesAnalyticDtoImpl({ + @JsonKey(name: 'organization_id') this.organizationId, + @JsonKey(name: 'outlet_id') this.outletId, + @JsonKey(name: 'date_from') this.dateFrom, + @JsonKey(name: 'date_to') this.dateTo, + @JsonKey(name: 'group_by') this.groupBy, + @JsonKey(name: 'summary') this.summary, + @JsonKey(name: 'data') final List? data, + }) : _data = data, + super._(); + + factory _$SalesAnalyticDtoImpl.fromJson(Map json) => + _$$SalesAnalyticDtoImplFromJson(json); + + @override + @JsonKey(name: 'organization_id') + final String? organizationId; + @override + @JsonKey(name: 'outlet_id') + final String? outletId; + @override + @JsonKey(name: 'date_from') + final DateTime? dateFrom; + @override + @JsonKey(name: 'date_to') + final DateTime? dateTo; + @override + @JsonKey(name: 'group_by') + final String? groupBy; + @override + @JsonKey(name: 'summary') + final SalesAnalyticSummaryDto? summary; + final List? _data; + @override + @JsonKey(name: 'data') + List? get data { + final value = _data; + if (value == null) return null; + if (_data is EqualUnmodifiableListView) return _data; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + String toString() { + return 'SalesAnalyticDto(organizationId: $organizationId, outletId: $outletId, dateFrom: $dateFrom, dateTo: $dateTo, groupBy: $groupBy, summary: $summary, data: $data)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SalesAnalyticDtoImpl && + (identical(other.organizationId, organizationId) || + other.organizationId == organizationId) && + (identical(other.outletId, outletId) || + other.outletId == outletId) && + (identical(other.dateFrom, dateFrom) || + other.dateFrom == dateFrom) && + (identical(other.dateTo, dateTo) || other.dateTo == dateTo) && + (identical(other.groupBy, groupBy) || other.groupBy == groupBy) && + (identical(other.summary, summary) || other.summary == summary) && + const DeepCollectionEquality().equals(other._data, _data)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + organizationId, + outletId, + dateFrom, + dateTo, + groupBy, + summary, + const DeepCollectionEquality().hash(_data), + ); + + /// Create a copy of SalesAnalyticDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SalesAnalyticDtoImplCopyWith<_$SalesAnalyticDtoImpl> get copyWith => + __$$SalesAnalyticDtoImplCopyWithImpl<_$SalesAnalyticDtoImpl>( + this, + _$identity, + ); + + @override + Map toJson() { + return _$$SalesAnalyticDtoImplToJson(this); + } +} + +abstract class _SalesAnalyticDto extends SalesAnalyticDto { + const factory _SalesAnalyticDto({ + @JsonKey(name: 'organization_id') final String? organizationId, + @JsonKey(name: 'outlet_id') final String? outletId, + @JsonKey(name: 'date_from') final DateTime? dateFrom, + @JsonKey(name: 'date_to') final DateTime? dateTo, + @JsonKey(name: 'group_by') final String? groupBy, + @JsonKey(name: 'summary') final SalesAnalyticSummaryDto? summary, + @JsonKey(name: 'data') final List? data, + }) = _$SalesAnalyticDtoImpl; + const _SalesAnalyticDto._() : super._(); + + factory _SalesAnalyticDto.fromJson(Map json) = + _$SalesAnalyticDtoImpl.fromJson; + + @override + @JsonKey(name: 'organization_id') + String? get organizationId; + @override + @JsonKey(name: 'outlet_id') + String? get outletId; + @override + @JsonKey(name: 'date_from') + DateTime? get dateFrom; + @override + @JsonKey(name: 'date_to') + DateTime? get dateTo; + @override + @JsonKey(name: 'group_by') + String? get groupBy; + @override + @JsonKey(name: 'summary') + SalesAnalyticSummaryDto? get summary; + @override + @JsonKey(name: 'data') + List? get data; + + /// Create a copy of SalesAnalyticDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SalesAnalyticDtoImplCopyWith<_$SalesAnalyticDtoImpl> get copyWith => + throw _privateConstructorUsedError; +} + +SalesAnalyticSummaryDto _$SalesAnalyticSummaryDtoFromJson( + Map json, +) { + return _SalesAnalyticSummaryDto.fromJson(json); +} + +/// @nodoc +mixin _$SalesAnalyticSummaryDto { + @JsonKey(name: 'total_sales') + num? get totalSales => throw _privateConstructorUsedError; + @JsonKey(name: 'total_orders') + num? get totalOrders => throw _privateConstructorUsedError; + @JsonKey(name: 'total_items') + num? get totalItems => throw _privateConstructorUsedError; + @JsonKey(name: 'average_order_value') + num? get averageOrderValue => throw _privateConstructorUsedError; + @JsonKey(name: 'total_tax') + num? get totalTax => throw _privateConstructorUsedError; + @JsonKey(name: 'total_discount') + num? get totalDiscount => throw _privateConstructorUsedError; + @JsonKey(name: 'net_sales') + num? get netSales => throw _privateConstructorUsedError; + + /// Serializes this SalesAnalyticSummaryDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of SalesAnalyticSummaryDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $SalesAnalyticSummaryDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SalesAnalyticSummaryDtoCopyWith<$Res> { + factory $SalesAnalyticSummaryDtoCopyWith( + SalesAnalyticSummaryDto value, + $Res Function(SalesAnalyticSummaryDto) then, + ) = _$SalesAnalyticSummaryDtoCopyWithImpl<$Res, SalesAnalyticSummaryDto>; + @useResult + $Res call({ + @JsonKey(name: 'total_sales') num? totalSales, + @JsonKey(name: 'total_orders') num? totalOrders, + @JsonKey(name: 'total_items') num? totalItems, + @JsonKey(name: 'average_order_value') num? averageOrderValue, + @JsonKey(name: 'total_tax') num? totalTax, + @JsonKey(name: 'total_discount') num? totalDiscount, + @JsonKey(name: 'net_sales') num? netSales, + }); +} + +/// @nodoc +class _$SalesAnalyticSummaryDtoCopyWithImpl< + $Res, + $Val extends SalesAnalyticSummaryDto +> + implements $SalesAnalyticSummaryDtoCopyWith<$Res> { + _$SalesAnalyticSummaryDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of SalesAnalyticSummaryDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? totalSales = freezed, + Object? totalOrders = freezed, + Object? totalItems = freezed, + Object? averageOrderValue = freezed, + Object? totalTax = freezed, + Object? totalDiscount = freezed, + Object? netSales = freezed, + }) { + return _then( + _value.copyWith( + totalSales: freezed == totalSales + ? _value.totalSales + : totalSales // ignore: cast_nullable_to_non_nullable + as num?, + totalOrders: freezed == totalOrders + ? _value.totalOrders + : totalOrders // ignore: cast_nullable_to_non_nullable + as num?, + totalItems: freezed == totalItems + ? _value.totalItems + : totalItems // ignore: cast_nullable_to_non_nullable + as num?, + averageOrderValue: freezed == averageOrderValue + ? _value.averageOrderValue + : averageOrderValue // ignore: cast_nullable_to_non_nullable + as num?, + totalTax: freezed == totalTax + ? _value.totalTax + : totalTax // ignore: cast_nullable_to_non_nullable + as num?, + totalDiscount: freezed == totalDiscount + ? _value.totalDiscount + : totalDiscount // ignore: cast_nullable_to_non_nullable + as num?, + netSales: freezed == netSales + ? _value.netSales + : netSales // ignore: cast_nullable_to_non_nullable + as num?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$SalesAnalyticSummaryDtoImplCopyWith<$Res> + implements $SalesAnalyticSummaryDtoCopyWith<$Res> { + factory _$$SalesAnalyticSummaryDtoImplCopyWith( + _$SalesAnalyticSummaryDtoImpl value, + $Res Function(_$SalesAnalyticSummaryDtoImpl) then, + ) = __$$SalesAnalyticSummaryDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: 'total_sales') num? totalSales, + @JsonKey(name: 'total_orders') num? totalOrders, + @JsonKey(name: 'total_items') num? totalItems, + @JsonKey(name: 'average_order_value') num? averageOrderValue, + @JsonKey(name: 'total_tax') num? totalTax, + @JsonKey(name: 'total_discount') num? totalDiscount, + @JsonKey(name: 'net_sales') num? netSales, + }); +} + +/// @nodoc +class __$$SalesAnalyticSummaryDtoImplCopyWithImpl<$Res> + extends + _$SalesAnalyticSummaryDtoCopyWithImpl< + $Res, + _$SalesAnalyticSummaryDtoImpl + > + implements _$$SalesAnalyticSummaryDtoImplCopyWith<$Res> { + __$$SalesAnalyticSummaryDtoImplCopyWithImpl( + _$SalesAnalyticSummaryDtoImpl _value, + $Res Function(_$SalesAnalyticSummaryDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of SalesAnalyticSummaryDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? totalSales = freezed, + Object? totalOrders = freezed, + Object? totalItems = freezed, + Object? averageOrderValue = freezed, + Object? totalTax = freezed, + Object? totalDiscount = freezed, + Object? netSales = freezed, + }) { + return _then( + _$SalesAnalyticSummaryDtoImpl( + totalSales: freezed == totalSales + ? _value.totalSales + : totalSales // ignore: cast_nullable_to_non_nullable + as num?, + totalOrders: freezed == totalOrders + ? _value.totalOrders + : totalOrders // ignore: cast_nullable_to_non_nullable + as num?, + totalItems: freezed == totalItems + ? _value.totalItems + : totalItems // ignore: cast_nullable_to_non_nullable + as num?, + averageOrderValue: freezed == averageOrderValue + ? _value.averageOrderValue + : averageOrderValue // ignore: cast_nullable_to_non_nullable + as num?, + totalTax: freezed == totalTax + ? _value.totalTax + : totalTax // ignore: cast_nullable_to_non_nullable + as num?, + totalDiscount: freezed == totalDiscount + ? _value.totalDiscount + : totalDiscount // ignore: cast_nullable_to_non_nullable + as num?, + netSales: freezed == netSales + ? _value.netSales + : netSales // ignore: cast_nullable_to_non_nullable + as num?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$SalesAnalyticSummaryDtoImpl extends _SalesAnalyticSummaryDto { + const _$SalesAnalyticSummaryDtoImpl({ + @JsonKey(name: 'total_sales') this.totalSales, + @JsonKey(name: 'total_orders') this.totalOrders, + @JsonKey(name: 'total_items') this.totalItems, + @JsonKey(name: 'average_order_value') this.averageOrderValue, + @JsonKey(name: 'total_tax') this.totalTax, + @JsonKey(name: 'total_discount') this.totalDiscount, + @JsonKey(name: 'net_sales') this.netSales, + }) : super._(); + + factory _$SalesAnalyticSummaryDtoImpl.fromJson(Map json) => + _$$SalesAnalyticSummaryDtoImplFromJson(json); + + @override + @JsonKey(name: 'total_sales') + final num? totalSales; + @override + @JsonKey(name: 'total_orders') + final num? totalOrders; + @override + @JsonKey(name: 'total_items') + final num? totalItems; + @override + @JsonKey(name: 'average_order_value') + final num? averageOrderValue; + @override + @JsonKey(name: 'total_tax') + final num? totalTax; + @override + @JsonKey(name: 'total_discount') + final num? totalDiscount; + @override + @JsonKey(name: 'net_sales') + final num? netSales; + + @override + String toString() { + return 'SalesAnalyticSummaryDto(totalSales: $totalSales, totalOrders: $totalOrders, totalItems: $totalItems, averageOrderValue: $averageOrderValue, totalTax: $totalTax, totalDiscount: $totalDiscount, netSales: $netSales)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SalesAnalyticSummaryDtoImpl && + (identical(other.totalSales, totalSales) || + other.totalSales == totalSales) && + (identical(other.totalOrders, totalOrders) || + other.totalOrders == totalOrders) && + (identical(other.totalItems, totalItems) || + other.totalItems == totalItems) && + (identical(other.averageOrderValue, averageOrderValue) || + other.averageOrderValue == averageOrderValue) && + (identical(other.totalTax, totalTax) || + other.totalTax == totalTax) && + (identical(other.totalDiscount, totalDiscount) || + other.totalDiscount == totalDiscount) && + (identical(other.netSales, netSales) || + other.netSales == netSales)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + totalSales, + totalOrders, + totalItems, + averageOrderValue, + totalTax, + totalDiscount, + netSales, + ); + + /// Create a copy of SalesAnalyticSummaryDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SalesAnalyticSummaryDtoImplCopyWith<_$SalesAnalyticSummaryDtoImpl> + get copyWith => + __$$SalesAnalyticSummaryDtoImplCopyWithImpl< + _$SalesAnalyticSummaryDtoImpl + >(this, _$identity); + + @override + Map toJson() { + return _$$SalesAnalyticSummaryDtoImplToJson(this); + } +} + +abstract class _SalesAnalyticSummaryDto extends SalesAnalyticSummaryDto { + const factory _SalesAnalyticSummaryDto({ + @JsonKey(name: 'total_sales') final num? totalSales, + @JsonKey(name: 'total_orders') final num? totalOrders, + @JsonKey(name: 'total_items') final num? totalItems, + @JsonKey(name: 'average_order_value') final num? averageOrderValue, + @JsonKey(name: 'total_tax') final num? totalTax, + @JsonKey(name: 'total_discount') final num? totalDiscount, + @JsonKey(name: 'net_sales') final num? netSales, + }) = _$SalesAnalyticSummaryDtoImpl; + const _SalesAnalyticSummaryDto._() : super._(); + + factory _SalesAnalyticSummaryDto.fromJson(Map json) = + _$SalesAnalyticSummaryDtoImpl.fromJson; + + @override + @JsonKey(name: 'total_sales') + num? get totalSales; + @override + @JsonKey(name: 'total_orders') + num? get totalOrders; + @override + @JsonKey(name: 'total_items') + num? get totalItems; + @override + @JsonKey(name: 'average_order_value') + num? get averageOrderValue; + @override + @JsonKey(name: 'total_tax') + num? get totalTax; + @override + @JsonKey(name: 'total_discount') + num? get totalDiscount; + @override + @JsonKey(name: 'net_sales') + num? get netSales; + + /// Create a copy of SalesAnalyticSummaryDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SalesAnalyticSummaryDtoImplCopyWith<_$SalesAnalyticSummaryDtoImpl> + get copyWith => throw _privateConstructorUsedError; +} + +SalesAnalyticDataDto _$SalesAnalyticDataDtoFromJson(Map json) { + return _SalesAnalyticDataDto.fromJson(json); +} + +/// @nodoc +mixin _$SalesAnalyticDataDto { + @JsonKey(name: 'date') + DateTime? get date => throw _privateConstructorUsedError; + @JsonKey(name: 'sales') + num? get sales => throw _privateConstructorUsedError; + @JsonKey(name: 'orders') + num? get orders => throw _privateConstructorUsedError; + @JsonKey(name: 'items') + num? get items => throw _privateConstructorUsedError; + @JsonKey(name: 'tax') + num? get tax => throw _privateConstructorUsedError; + @JsonKey(name: 'discount') + num? get discount => throw _privateConstructorUsedError; + @JsonKey(name: 'net_sales') + num? get netSales => throw _privateConstructorUsedError; + + /// Serializes this SalesAnalyticDataDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of SalesAnalyticDataDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $SalesAnalyticDataDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SalesAnalyticDataDtoCopyWith<$Res> { + factory $SalesAnalyticDataDtoCopyWith( + SalesAnalyticDataDto value, + $Res Function(SalesAnalyticDataDto) then, + ) = _$SalesAnalyticDataDtoCopyWithImpl<$Res, SalesAnalyticDataDto>; + @useResult + $Res call({ + @JsonKey(name: 'date') DateTime? date, + @JsonKey(name: 'sales') num? sales, + @JsonKey(name: 'orders') num? orders, + @JsonKey(name: 'items') num? items, + @JsonKey(name: 'tax') num? tax, + @JsonKey(name: 'discount') num? discount, + @JsonKey(name: 'net_sales') num? netSales, + }); +} + +/// @nodoc +class _$SalesAnalyticDataDtoCopyWithImpl< + $Res, + $Val extends SalesAnalyticDataDto +> + implements $SalesAnalyticDataDtoCopyWith<$Res> { + _$SalesAnalyticDataDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of SalesAnalyticDataDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? date = freezed, + Object? sales = freezed, + Object? orders = freezed, + Object? items = freezed, + Object? tax = freezed, + Object? discount = freezed, + Object? netSales = freezed, + }) { + return _then( + _value.copyWith( + date: freezed == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as DateTime?, + sales: freezed == sales + ? _value.sales + : sales // ignore: cast_nullable_to_non_nullable + as num?, + orders: freezed == orders + ? _value.orders + : orders // ignore: cast_nullable_to_non_nullable + as num?, + items: freezed == items + ? _value.items + : items // ignore: cast_nullable_to_non_nullable + as num?, + tax: freezed == tax + ? _value.tax + : tax // ignore: cast_nullable_to_non_nullable + as num?, + discount: freezed == discount + ? _value.discount + : discount // ignore: cast_nullable_to_non_nullable + as num?, + netSales: freezed == netSales + ? _value.netSales + : netSales // ignore: cast_nullable_to_non_nullable + as num?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$SalesAnalyticDataDtoImplCopyWith<$Res> + implements $SalesAnalyticDataDtoCopyWith<$Res> { + factory _$$SalesAnalyticDataDtoImplCopyWith( + _$SalesAnalyticDataDtoImpl value, + $Res Function(_$SalesAnalyticDataDtoImpl) then, + ) = __$$SalesAnalyticDataDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: 'date') DateTime? date, + @JsonKey(name: 'sales') num? sales, + @JsonKey(name: 'orders') num? orders, + @JsonKey(name: 'items') num? items, + @JsonKey(name: 'tax') num? tax, + @JsonKey(name: 'discount') num? discount, + @JsonKey(name: 'net_sales') num? netSales, + }); +} + +/// @nodoc +class __$$SalesAnalyticDataDtoImplCopyWithImpl<$Res> + extends _$SalesAnalyticDataDtoCopyWithImpl<$Res, _$SalesAnalyticDataDtoImpl> + implements _$$SalesAnalyticDataDtoImplCopyWith<$Res> { + __$$SalesAnalyticDataDtoImplCopyWithImpl( + _$SalesAnalyticDataDtoImpl _value, + $Res Function(_$SalesAnalyticDataDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of SalesAnalyticDataDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? date = freezed, + Object? sales = freezed, + Object? orders = freezed, + Object? items = freezed, + Object? tax = freezed, + Object? discount = freezed, + Object? netSales = freezed, + }) { + return _then( + _$SalesAnalyticDataDtoImpl( + date: freezed == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as DateTime?, + sales: freezed == sales + ? _value.sales + : sales // ignore: cast_nullable_to_non_nullable + as num?, + orders: freezed == orders + ? _value.orders + : orders // ignore: cast_nullable_to_non_nullable + as num?, + items: freezed == items + ? _value.items + : items // ignore: cast_nullable_to_non_nullable + as num?, + tax: freezed == tax + ? _value.tax + : tax // ignore: cast_nullable_to_non_nullable + as num?, + discount: freezed == discount + ? _value.discount + : discount // ignore: cast_nullable_to_non_nullable + as num?, + netSales: freezed == netSales + ? _value.netSales + : netSales // ignore: cast_nullable_to_non_nullable + as num?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$SalesAnalyticDataDtoImpl extends _SalesAnalyticDataDto { + const _$SalesAnalyticDataDtoImpl({ + @JsonKey(name: 'date') this.date, + @JsonKey(name: 'sales') this.sales, + @JsonKey(name: 'orders') this.orders, + @JsonKey(name: 'items') this.items, + @JsonKey(name: 'tax') this.tax, + @JsonKey(name: 'discount') this.discount, + @JsonKey(name: 'net_sales') this.netSales, + }) : super._(); + + factory _$SalesAnalyticDataDtoImpl.fromJson(Map json) => + _$$SalesAnalyticDataDtoImplFromJson(json); + + @override + @JsonKey(name: 'date') + final DateTime? date; + @override + @JsonKey(name: 'sales') + final num? sales; + @override + @JsonKey(name: 'orders') + final num? orders; + @override + @JsonKey(name: 'items') + final num? items; + @override + @JsonKey(name: 'tax') + final num? tax; + @override + @JsonKey(name: 'discount') + final num? discount; + @override + @JsonKey(name: 'net_sales') + final num? netSales; + + @override + String toString() { + return 'SalesAnalyticDataDto(date: $date, sales: $sales, orders: $orders, items: $items, tax: $tax, discount: $discount, netSales: $netSales)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SalesAnalyticDataDtoImpl && + (identical(other.date, date) || other.date == date) && + (identical(other.sales, sales) || other.sales == sales) && + (identical(other.orders, orders) || other.orders == orders) && + (identical(other.items, items) || other.items == items) && + (identical(other.tax, tax) || other.tax == tax) && + (identical(other.discount, discount) || + other.discount == discount) && + (identical(other.netSales, netSales) || + other.netSales == netSales)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + date, + sales, + orders, + items, + tax, + discount, + netSales, + ); + + /// Create a copy of SalesAnalyticDataDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SalesAnalyticDataDtoImplCopyWith<_$SalesAnalyticDataDtoImpl> + get copyWith => + __$$SalesAnalyticDataDtoImplCopyWithImpl<_$SalesAnalyticDataDtoImpl>( + this, + _$identity, + ); + + @override + Map toJson() { + return _$$SalesAnalyticDataDtoImplToJson(this); + } +} + +abstract class _SalesAnalyticDataDto extends SalesAnalyticDataDto { + const factory _SalesAnalyticDataDto({ + @JsonKey(name: 'date') final DateTime? date, + @JsonKey(name: 'sales') final num? sales, + @JsonKey(name: 'orders') final num? orders, + @JsonKey(name: 'items') final num? items, + @JsonKey(name: 'tax') final num? tax, + @JsonKey(name: 'discount') final num? discount, + @JsonKey(name: 'net_sales') final num? netSales, + }) = _$SalesAnalyticDataDtoImpl; + const _SalesAnalyticDataDto._() : super._(); + + factory _SalesAnalyticDataDto.fromJson(Map json) = + _$SalesAnalyticDataDtoImpl.fromJson; + + @override + @JsonKey(name: 'date') + DateTime? get date; + @override + @JsonKey(name: 'sales') + num? get sales; + @override + @JsonKey(name: 'orders') + num? get orders; + @override + @JsonKey(name: 'items') + num? get items; + @override + @JsonKey(name: 'tax') + num? get tax; + @override + @JsonKey(name: 'discount') + num? get discount; + @override + @JsonKey(name: 'net_sales') + num? get netSales; + + /// Create a copy of SalesAnalyticDataDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SalesAnalyticDataDtoImplCopyWith<_$SalesAnalyticDataDtoImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/infrastructure/analytic/analytic_dtos.g.dart b/lib/infrastructure/analytic/analytic_dtos.g.dart new file mode 100644 index 0000000..ebd7a0a --- /dev/null +++ b/lib/infrastructure/analytic/analytic_dtos.g.dart @@ -0,0 +1,89 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'analytic_dtos.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$SalesAnalyticDtoImpl _$$SalesAnalyticDtoImplFromJson( + Map json, +) => _$SalesAnalyticDtoImpl( + organizationId: json['organization_id'] as String?, + outletId: json['outlet_id'] as String?, + dateFrom: json['date_from'] == null + ? null + : DateTime.parse(json['date_from'] as String), + dateTo: json['date_to'] == null + ? null + : DateTime.parse(json['date_to'] as String), + groupBy: json['group_by'] as String?, + summary: json['summary'] == null + ? null + : SalesAnalyticSummaryDto.fromJson( + json['summary'] as Map, + ), + data: (json['data'] as List?) + ?.map((e) => SalesAnalyticDataDto.fromJson(e as Map)) + .toList(), +); + +Map _$$SalesAnalyticDtoImplToJson( + _$SalesAnalyticDtoImpl instance, +) => { + 'organization_id': instance.organizationId, + 'outlet_id': instance.outletId, + 'date_from': instance.dateFrom?.toIso8601String(), + 'date_to': instance.dateTo?.toIso8601String(), + 'group_by': instance.groupBy, + 'summary': instance.summary, + 'data': instance.data, +}; + +_$SalesAnalyticSummaryDtoImpl _$$SalesAnalyticSummaryDtoImplFromJson( + Map json, +) => _$SalesAnalyticSummaryDtoImpl( + totalSales: json['total_sales'] as num?, + totalOrders: json['total_orders'] as num?, + totalItems: json['total_items'] as num?, + averageOrderValue: json['average_order_value'] as num?, + totalTax: json['total_tax'] as num?, + totalDiscount: json['total_discount'] as num?, + netSales: json['net_sales'] as num?, +); + +Map _$$SalesAnalyticSummaryDtoImplToJson( + _$SalesAnalyticSummaryDtoImpl instance, +) => { + 'total_sales': instance.totalSales, + 'total_orders': instance.totalOrders, + 'total_items': instance.totalItems, + 'average_order_value': instance.averageOrderValue, + 'total_tax': instance.totalTax, + 'total_discount': instance.totalDiscount, + 'net_sales': instance.netSales, +}; + +_$SalesAnalyticDataDtoImpl _$$SalesAnalyticDataDtoImplFromJson( + Map json, +) => _$SalesAnalyticDataDtoImpl( + date: json['date'] == null ? null : DateTime.parse(json['date'] as String), + sales: json['sales'] as num?, + orders: json['orders'] as num?, + items: json['items'] as num?, + tax: json['tax'] as num?, + discount: json['discount'] as num?, + netSales: json['net_sales'] as num?, +); + +Map _$$SalesAnalyticDataDtoImplToJson( + _$SalesAnalyticDataDtoImpl instance, +) => { + 'date': instance.date?.toIso8601String(), + 'sales': instance.sales, + 'orders': instance.orders, + 'items': instance.items, + 'tax': instance.tax, + 'discount': instance.discount, + 'net_sales': instance.netSales, +}; diff --git a/lib/infrastructure/analytic/datasource/remote_data_provider.dart b/lib/infrastructure/analytic/datasource/remote_data_provider.dart new file mode 100644 index 0000000..c5827b1 --- /dev/null +++ b/lib/infrastructure/analytic/datasource/remote_data_provider.dart @@ -0,0 +1,45 @@ +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/extension/extension.dart'; +import '../../../common/url/api_path.dart'; +import '../../../domain/analytic/analytic.dart'; +import '../analytic_dtos.dart'; + +@injectable +class AnalyticRemoteDataProvider { + final ApiClient _apiClient; + final String _logName = "AnalyticRemoteDataProvider"; + + AnalyticRemoteDataProvider(this._apiClient); + + Future> fetchSales({ + required DateTime dateFrom, + required DateTime dateTo, + }) async { + try { + final response = await _apiClient.get( + ApiPath.salesAnalytic, + params: { + 'date_from': dateFrom.toServerDate, + 'date_to': dateTo.toServerDate, + }, + ); + + if (response.data['data'] == null) { + return DC.error(AnalyticFailure.empty()); + } + + final dto = SalesAnalyticDto.fromJson(response.data['data']); + + return DC.data(dto); + } on ApiFailure catch (e, s) { + log('fetchSalesError', name: _logName, error: e, stackTrace: s); + return DC.error(AnalyticFailure.serverError(e)); + } + } +} diff --git a/lib/infrastructure/analytic/dto/sales_analytic_dto.dart b/lib/infrastructure/analytic/dto/sales_analytic_dto.dart new file mode 100644 index 0000000..c4453c9 --- /dev/null +++ b/lib/infrastructure/analytic/dto/sales_analytic_dto.dart @@ -0,0 +1,85 @@ +part of '../analytic_dtos.dart'; + +@freezed +class SalesAnalyticDto with _$SalesAnalyticDto { + const SalesAnalyticDto._(); + + const factory SalesAnalyticDto({ + @JsonKey(name: 'organization_id') String? organizationId, + @JsonKey(name: 'outlet_id') String? outletId, + @JsonKey(name: 'date_from') DateTime? dateFrom, + @JsonKey(name: 'date_to') DateTime? dateTo, + @JsonKey(name: 'group_by') String? groupBy, + @JsonKey(name: 'summary') SalesAnalyticSummaryDto? summary, + @JsonKey(name: 'data') List? data, + }) = _SalesAnalyticDto; + + factory SalesAnalyticDto.fromJson(Map json) => + _$SalesAnalyticDtoFromJson(json); + + SalesAnalytic toDomain() => SalesAnalytic( + organizationId: organizationId ?? '', + outletId: outletId ?? '', + dateFrom: dateFrom ?? DateTime.fromMillisecondsSinceEpoch(0), + dateTo: dateTo ?? DateTime.fromMillisecondsSinceEpoch(0), + groupBy: groupBy ?? '', + summary: summary?.toDomain() ?? SalesAnalyticSummary.empty(), + data: data?.map((e) => e.toDomain()).toList() ?? [], + ); +} + +@freezed +class SalesAnalyticSummaryDto with _$SalesAnalyticSummaryDto { + const SalesAnalyticSummaryDto._(); + + const factory SalesAnalyticSummaryDto({ + @JsonKey(name: 'total_sales') num? totalSales, + @JsonKey(name: 'total_orders') num? totalOrders, + @JsonKey(name: 'total_items') num? totalItems, + @JsonKey(name: 'average_order_value') num? averageOrderValue, + @JsonKey(name: 'total_tax') num? totalTax, + @JsonKey(name: 'total_discount') num? totalDiscount, + @JsonKey(name: 'net_sales') num? netSales, + }) = _SalesAnalyticSummaryDto; + + factory SalesAnalyticSummaryDto.fromJson(Map json) => + _$SalesAnalyticSummaryDtoFromJson(json); + + SalesAnalyticSummary toDomain() => SalesAnalyticSummary( + totalSales: totalSales?.toInt() ?? 0, + totalOrders: totalOrders?.toInt() ?? 0, + totalItems: totalItems?.toInt() ?? 0, + averageOrderValue: averageOrderValue?.toDouble() ?? 0, + totalTax: totalTax?.toInt() ?? 0, + totalDiscount: totalDiscount?.toInt() ?? 0, + netSales: netSales?.toInt() ?? 0, + ); +} + +@freezed +class SalesAnalyticDataDto with _$SalesAnalyticDataDto { + const SalesAnalyticDataDto._(); + + const factory SalesAnalyticDataDto({ + @JsonKey(name: 'date') DateTime? date, + @JsonKey(name: 'sales') num? sales, + @JsonKey(name: 'orders') num? orders, + @JsonKey(name: 'items') num? items, + @JsonKey(name: 'tax') num? tax, + @JsonKey(name: 'discount') num? discount, + @JsonKey(name: 'net_sales') num? netSales, + }) = _SalesAnalyticDataDto; + + factory SalesAnalyticDataDto.fromJson(Map json) => + _$SalesAnalyticDataDtoFromJson(json); + + SalesAnalyticData toDomain() => SalesAnalyticData( + date: date ?? DateTime.fromMillisecondsSinceEpoch(0), + sales: sales?.toInt() ?? 0, + orders: orders?.toInt() ?? 0, + items: items?.toInt() ?? 0, + tax: tax?.toInt() ?? 0, + discount: discount?.toInt() ?? 0, + netSales: netSales?.toInt() ?? 0, + ); +} diff --git a/lib/infrastructure/analytic/repositories/analytic_repository.dart b/lib/infrastructure/analytic/repositories/analytic_repository.dart new file mode 100644 index 0000000..a615956 --- /dev/null +++ b/lib/infrastructure/analytic/repositories/analytic_repository.dart @@ -0,0 +1,40 @@ +import 'dart:developer'; + +import 'package:dartz/dartz.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/analytic/analytic.dart'; +import '../../../domain/analytic/repositories/i_analytic_repository.dart'; +import '../datasource/remote_data_provider.dart'; + +@Injectable(as: IAnalyticRepository) +class AnalyticRepository implements IAnalyticRepository { + final AnalyticRemoteDataProvider _dataProvider; + final String _logName = 'AnalyticRepository'; + + AnalyticRepository(this._dataProvider); + + @override + Future> getSales({ + required DateTime dateFrom, + required DateTime dateTo, + }) async { + try { + final result = await _dataProvider.fetchSales( + dateFrom: dateFrom, + dateTo: dateTo, + ); + + if (result.hasError) { + return left(result.error!); + } + + final auth = result.data!.toDomain(); + + return right(auth); + } catch (e, s) { + log('getSalesError', name: _logName, error: e, stackTrace: s); + return left(const AnalyticFailure.unexpectedError()); + } + } +} diff --git a/lib/injection.config.dart b/lib/injection.config.dart index 7cd1c34..88c9774 100644 --- a/lib/injection.config.dart +++ b/lib/injection.config.dart @@ -16,6 +16,8 @@ import 'package:apskel_owner_flutter/application/auth/logout_form/logout_form_bl as _i574; import 'package:apskel_owner_flutter/application/language/language_bloc.dart' as _i455; +import 'package:apskel_owner_flutter/application/sales/sales_loader/sales_loader_bloc.dart' + as _i882; import 'package:apskel_owner_flutter/common/api/api_client.dart' as _i115; import 'package:apskel_owner_flutter/common/di/di_auto_route.dart' as _i311; import 'package:apskel_owner_flutter/common/di/di_connectivity.dart' as _i586; @@ -25,8 +27,14 @@ import 'package:apskel_owner_flutter/common/di/di_shared_preferences.dart' as _i402; import 'package:apskel_owner_flutter/common/network/network_client.dart' as _i543; +import 'package:apskel_owner_flutter/domain/analytic/repositories/i_analytic_repository.dart' + as _i477; import 'package:apskel_owner_flutter/domain/auth/auth.dart' as _i49; import 'package:apskel_owner_flutter/env.dart' as _i6; +import 'package:apskel_owner_flutter/infrastructure/analytic/datasource/remote_data_provider.dart' + as _i866; +import 'package:apskel_owner_flutter/infrastructure/analytic/repositories/analytic_repository.dart' + as _i393; import 'package:apskel_owner_flutter/infrastructure/auth/datasources/local_data_provider.dart' as _i991; import 'package:apskel_owner_flutter/infrastructure/auth/datasources/remote_data_provider.dart' @@ -89,12 +97,21 @@ extension GetItInjectableX on _i174.GetIt { gh.factory<_i17.AuthRemoteDataProvider>( () => _i17.AuthRemoteDataProvider(gh<_i115.ApiClient>()), ); + gh.factory<_i866.AnalyticRemoteDataProvider>( + () => _i866.AnalyticRemoteDataProvider(gh<_i115.ApiClient>()), + ); + gh.factory<_i477.IAnalyticRepository>( + () => _i393.AnalyticRepository(gh<_i866.AnalyticRemoteDataProvider>()), + ); gh.factory<_i49.IAuthRepository>( () => _i1035.AuthRepository( gh<_i991.AuthLocalDataProvider>(), gh<_i17.AuthRemoteDataProvider>(), ), ); + gh.factory<_i882.SalesLoaderBloc>( + () => _i882.SalesLoaderBloc(gh<_i477.IAnalyticRepository>()), + ); gh.factory<_i775.LoginFormBloc>( () => _i775.LoginFormBloc(gh<_i49.IAuthRepository>()), ); diff --git a/lib/presentation/pages/sales/sales_page.dart b/lib/presentation/pages/sales/sales_page.dart index 33d4368..71d4f3a 100644 --- a/lib/presentation/pages/sales/sales_page.dart +++ b/lib/presentation/pages/sales/sales_page.dart @@ -1,72 +1,29 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import '../../../application/sales/sales_loader/sales_loader_bloc.dart'; +import '../../../common/extension/extension.dart'; import '../../../common/theme/theme.dart'; +import '../../../domain/analytic/analytic.dart'; +import '../../../injection.dart'; import '../../components/appbar/appbar.dart'; import '../../components/spacer/spacer.dart'; import 'widgets/summary_card.dart'; -// Data Models -class SalesData { - final String dateFrom; - final String dateTo; - final SalesSummary summary; - final List dailySales; - - SalesData({ - required this.dateFrom, - required this.dateTo, - required this.summary, - required this.dailySales, - }); -} - -class SalesSummary { - final double totalSales; - final int totalOrders; - final int totalItems; - final double averageOrderValue; - final double totalTax; - final double totalDiscount; - final double netSales; - - SalesSummary({ - required this.totalSales, - required this.totalOrders, - required this.totalItems, - required this.averageOrderValue, - required this.totalTax, - required this.totalDiscount, - required this.netSales, - }); -} - -class DailySales { - final DateTime date; - final double sales; - final int orders; - final int items; - final double tax; - final double discount; - final double netSales; - - DailySales({ - required this.date, - required this.sales, - required this.orders, - required this.items, - required this.tax, - required this.discount, - required this.netSales, - }); -} - @RoutePage() -class SalesPage extends StatefulWidget { +class SalesPage extends StatefulWidget implements AutoRouteWrapper { const SalesPage({super.key}); @override State createState() => _SalesPageState(); + + @override + Widget wrappedRoute(BuildContext context) => BlocProvider( + create: (context) => + getIt()..add(SalesLoaderEvent.fectched()), + child: this, + ); } class _SalesPageState extends State with TickerProviderStateMixin { @@ -115,379 +72,359 @@ class _SalesPageState extends State with TickerProviderStateMixin { super.dispose(); } - // Sample data based on your JSON - final SalesData salesData = SalesData( - dateFrom: "2025-08-01T00:00:00+07:00", - dateTo: "2025-08-15T23:59:59.999999999+07:00", - summary: SalesSummary( - totalSales: 4291000, - totalOrders: 62, - totalItems: 62, - averageOrderValue: 69209.67741935483, - totalTax: 0, - totalDiscount: 0, - netSales: 4291000, - ), - dailySales: [ - DailySales( - date: DateTime.parse("2025-08-13T00:00:00Z"), - sales: 3841000, - orders: 52, - items: 52, - tax: 0, - discount: 0, - netSales: 3841000, - ), - DailySales( - date: DateTime.parse("2025-08-14T00:00:00Z"), - sales: 450000, - orders: 10, - items: 10, - tax: 0, - discount: 0, - netSales: 450000, - ), - ], - ); - - String formatCurrency(double amount) { - return 'Rp ${amount.toStringAsFixed(0).replaceAllMapped(RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'), (Match m) => '${m[1]}.')}'; - } - @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColor.background, - body: CustomScrollView( - slivers: [ - // App Bar - SliverAppBar( - expandedHeight: 120, - floating: false, - pinned: true, - backgroundColor: AppColor.primary, - flexibleSpace: CustomAppBar(title: 'Penjualan'), - ), + body: BlocBuilder( + builder: (context, state) { + return CustomScrollView( + slivers: [ + // App Bar + SliverAppBar( + expandedHeight: 120, + floating: false, + pinned: true, + backgroundColor: AppColor.primary, + flexibleSpace: CustomAppBar(title: 'Penjualan'), + ), - // Date Range Header - SliverToBoxAdapter( - child: SlideTransition( - position: slideAnimation, - child: FadeTransition( - opacity: fadeAnimation, - child: Container( - margin: const EdgeInsets.all(16), - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 12, - ), - decoration: BoxDecoration( - color: AppColor.surface, - borderRadius: BorderRadius.circular(12), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.05), - blurRadius: 10, - offset: const Offset(0, 2), + // Date Range Header + SliverToBoxAdapter( + child: SlideTransition( + position: slideAnimation, + child: FadeTransition( + opacity: fadeAnimation, + child: Container( + margin: const EdgeInsets.all(16), + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 12, ), - ], - ), - child: Row( - children: [ - Icon(Icons.date_range, color: AppColor.primary, size: 20), - SpaceWidth(8), - Text( - 'Aug 1 - Aug 15, 2025', - style: AppStyle.md.copyWith( - color: AppColor.textPrimary, - fontWeight: FontWeight.w500, - ), + decoration: BoxDecoration( + color: AppColor.surface, + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.05), + blurRadius: 10, + offset: const Offset(0, 2), + ), + ], ), - ], + child: Row( + children: [ + Icon( + Icons.date_range, + color: AppColor.primary, + size: 20, + ), + SpaceWidth(8), + Text( + 'Aug 1 - Aug 15, 2025', + style: AppStyle.md.copyWith( + color: AppColor.textPrimary, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), ), ), ), - ), - ), - // Summary Cards - SliverToBoxAdapter( - child: SlideTransition( - position: slideAnimation, - child: FadeTransition( - opacity: fadeAnimation, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Summary', - style: AppStyle.xxl.copyWith( + // Summary Cards + SliverToBoxAdapter( + child: SlideTransition( + position: slideAnimation, + child: FadeTransition( + opacity: fadeAnimation, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Summary', + style: AppStyle.xxl.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.textPrimary, + ), + ), + const SpaceHeight(16), + TweenAnimationBuilder( + tween: Tween(begin: 0.0, end: 1.0), + duration: const Duration(milliseconds: 800), + curve: Curves.elasticOut, + builder: (context, value, child) { + return Transform.scale( + scale: value, + child: Row( + children: [ + Expanded( + child: _buildSummaryCard( + 'Total Sales', + state + .sales + .summary + .totalSales + .currencyFormatRp, + Icons.trending_up, + AppColor.success, + 0, + ), + ), + SpaceWidth(12), + Expanded( + child: _buildSummaryCard( + 'Total Orders', + state.sales.summary.totalOrders + .toString(), + Icons.shopping_cart, + AppColor.info, + 100, + ), + ), + ], + ), + ); + }, + ), + const SpaceHeight(12), + TweenAnimationBuilder( + tween: Tween(begin: 0.0, end: 1.0), + duration: const Duration(milliseconds: 1000), + curve: Curves.elasticOut, + builder: (context, value, child) { + return Transform.scale( + scale: value, + child: Row( + children: [ + Expanded( + child: _buildSummaryCard( + 'Avg Order Value', + state.sales.summary.averageOrderValue + .round() + .currencyFormatRp, + Icons.attach_money, + AppColor.warning, + 200, + ), + ), + SpaceWidth(12), + Expanded( + child: _buildSummaryCard( + 'Total Items', + state.sales.summary.totalItems + .toString(), + Icons.inventory, + AppColor.primary, + 300, + ), + ), + ], + ), + ); + }, + ), + ], + ), + ), + ), + ), + ), + + // Net Sales Card + SliverToBoxAdapter( + child: SlideTransition( + position: slideAnimation, + child: FadeTransition( + opacity: fadeAnimation, + child: TweenAnimationBuilder( + tween: Tween(begin: 0.0, end: 1.0), + duration: const Duration(milliseconds: 1200), + curve: Curves.bounceOut, + builder: (context, value, child) { + return Transform.scale( + scale: value, + child: Container( + margin: const EdgeInsets.all(16), + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + gradient: const LinearGradient( + colors: AppColor.successGradient, + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: AppColor.success.withOpacity(0.3), + blurRadius: 15, + offset: const Offset(0, 5), + ), + ], + ), + child: Row( + children: [ + TweenAnimationBuilder( + tween: Tween(begin: 0.0, end: 1.0), + duration: const Duration(milliseconds: 1500), + curve: Curves.elasticOut, + builder: (context, iconValue, child) { + return Transform.rotate( + angle: iconValue * 0.1, + child: Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.2), + borderRadius: BorderRadius.circular( + 12, + ), + ), + child: const Icon( + Icons.account_balance_wallet, + color: AppColor.textWhite, + size: 28, + ), + ), + ); + }, + ), + SpaceWidth(16), + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + 'Net Sales', + style: TextStyle( + color: AppColor.textWhite.withOpacity( + 0.9, + ), + fontSize: 14, + fontWeight: FontWeight.w500, + ), + ), + const SpaceHeight(4), + TweenAnimationBuilder( + tween: Tween( + begin: 0.0, + end: state.sales.summary.netSales + .toDouble(), + ), + duration: const Duration( + milliseconds: 2000, + ), + curve: Curves.easeOutCubic, + builder: (context, countValue, child) { + return Text( + state + .sales + .summary + .netSales + .currencyFormatRp, + style: const TextStyle( + color: AppColor.textWhite, + fontSize: 24, + fontWeight: FontWeight.bold, + ), + ); + }, + ), + ], + ), + ), + ], + ), + ), + ); + }, + ), + ), + ), + ), + + // Daily Sales Section Header + SliverToBoxAdapter( + child: SlideTransition( + position: slideAnimation, + child: FadeTransition( + opacity: fadeAnimation, + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 8, 16, 16), + child: Text( + 'Daily Breakdown', + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold, color: AppColor.textPrimary, ), ), - const SpaceHeight(16), - TweenAnimationBuilder( - tween: Tween(begin: 0.0, end: 1.0), - duration: const Duration(milliseconds: 800), - curve: Curves.elasticOut, - builder: (context, value, child) { - return Transform.scale( - scale: value, - child: Row( - children: [ - Expanded( - child: _buildSummaryCard( - 'Total Sales', - formatCurrency( - salesData.summary.totalSales, - ), - Icons.trending_up, - AppColor.success, - 0, - ), - ), - SpaceWidth(12), - Expanded( - child: _buildSummaryCard( - 'Total Orders', - '${salesData.summary.totalOrders}', - Icons.shopping_cart, - AppColor.info, - 100, - ), - ), - ], - ), - ); - }, - ), - const SpaceHeight(12), - TweenAnimationBuilder( - tween: Tween(begin: 0.0, end: 1.0), - duration: const Duration(milliseconds: 1000), - curve: Curves.elasticOut, - builder: (context, value, child) { - return Transform.scale( - scale: value, - child: Row( - children: [ - Expanded( - child: _buildSummaryCard( - 'Avg Order Value', - formatCurrency( - salesData.summary.averageOrderValue, - ), - Icons.attach_money, - AppColor.warning, - 200, - ), - ), - SpaceWidth(12), - Expanded( - child: _buildSummaryCard( - 'Total Items', - '${salesData.summary.totalItems}', - Icons.inventory, - AppColor.primary, - 300, - ), - ), - ], - ), - ); - }, - ), - ], + ), ), ), ), - ), - ), - // Net Sales Card - SliverToBoxAdapter( - child: SlideTransition( - position: slideAnimation, - child: FadeTransition( - opacity: fadeAnimation, - child: TweenAnimationBuilder( - tween: Tween(begin: 0.0, end: 1.0), - duration: const Duration(milliseconds: 1200), - curve: Curves.bounceOut, - builder: (context, value, child) { - return Transform.scale( - scale: value, - child: Container( - margin: const EdgeInsets.all(16), - padding: const EdgeInsets.all(20), - decoration: BoxDecoration( - gradient: const LinearGradient( - colors: AppColor.successGradient, - begin: Alignment.topLeft, - end: Alignment.bottomRight, + // Daily Sales List + SliverList( + delegate: SliverChildBuilderDelegate((context, index) { + return SlideTransition( + position: + Tween( + begin: Offset(index.isEven ? -1.0 : 1.0, 0), + end: Offset.zero, + ).animate( + CurvedAnimation( + parent: slideAnimationController, + curve: Interval( + 0.2 + (index * 0.1), + 0.8 + (index * 0.1), + curve: Curves.easeOutBack, + ), ), - borderRadius: BorderRadius.circular(16), + ), + child: FadeTransition( + opacity: Tween(begin: 0.0, end: 1.0).animate( + CurvedAnimation( + parent: fadeAnimationController, + curve: Interval( + 0.3 + (index * 0.1), + 0.9 + (index * 0.1), + curve: Curves.easeOut, + ), + ), + ), + child: Container( + margin: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 6, + ), + decoration: BoxDecoration( + color: AppColor.surface, + borderRadius: BorderRadius.circular(12), boxShadow: [ BoxShadow( - color: AppColor.success.withOpacity(0.3), - blurRadius: 15, - offset: const Offset(0, 5), - ), - ], - ), - child: Row( - children: [ - TweenAnimationBuilder( - tween: Tween(begin: 0.0, end: 1.0), - duration: const Duration(milliseconds: 1500), - curve: Curves.elasticOut, - builder: (context, iconValue, child) { - return Transform.rotate( - angle: iconValue * 0.1, - child: Container( - padding: const EdgeInsets.all(12), - decoration: BoxDecoration( - color: Colors.white.withOpacity(0.2), - borderRadius: BorderRadius.circular(12), - ), - child: const Icon( - Icons.account_balance_wallet, - color: AppColor.textWhite, - size: 28, - ), - ), - ); - }, - ), - SpaceWidth(16), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Net Sales', - style: TextStyle( - color: AppColor.textWhite.withOpacity( - 0.9, - ), - fontSize: 14, - fontWeight: FontWeight.w500, - ), - ), - const SpaceHeight(4), - TweenAnimationBuilder( - tween: Tween( - begin: 0.0, - end: salesData.summary.netSales, - ), - duration: const Duration( - milliseconds: 2000, - ), - curve: Curves.easeOutCubic, - builder: (context, countValue, child) { - return Text( - formatCurrency(countValue), - style: const TextStyle( - color: AppColor.textWhite, - fontSize: 24, - fontWeight: FontWeight.bold, - ), - ); - }, - ), - ], - ), + color: Colors.black.withOpacity(0.05), + blurRadius: 8, + offset: const Offset(0, 2), ), ], ), + child: _buildDailySalesItem(state.sales.data[index]), ), - ); - }, - ), + ), + ); + }, childCount: state.sales.data.length), ), - ), - ), - // Daily Sales Section Header - SliverToBoxAdapter( - child: SlideTransition( - position: slideAnimation, - child: FadeTransition( - opacity: fadeAnimation, - child: Padding( - padding: const EdgeInsets.fromLTRB(16, 8, 16, 16), - child: Text( - 'Daily Breakdown', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: AppColor.textPrimary, - ), - ), - ), - ), - ), - ), - - // Daily Sales List - SliverList( - delegate: SliverChildBuilderDelegate((context, index) { - final dailySale = salesData.dailySales[index]; - return SlideTransition( - position: - Tween( - begin: Offset(index.isEven ? -1.0 : 1.0, 0), - end: Offset.zero, - ).animate( - CurvedAnimation( - parent: slideAnimationController, - curve: Interval( - 0.2 + (index * 0.1), - 0.8 + (index * 0.1), - curve: Curves.easeOutBack, - ), - ), - ), - child: FadeTransition( - opacity: Tween(begin: 0.0, end: 1.0).animate( - CurvedAnimation( - parent: fadeAnimationController, - curve: Interval( - 0.3 + (index * 0.1), - 0.9 + (index * 0.1), - curve: Curves.easeOut, - ), - ), - ), - child: Container( - margin: const EdgeInsets.symmetric( - horizontal: 16, - vertical: 6, - ), - decoration: BoxDecoration( - color: AppColor.surface, - borderRadius: BorderRadius.circular(12), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.05), - blurRadius: 8, - offset: const Offset(0, 2), - ), - ], - ), - child: _buildDailySalesItem(dailySale), - ), - ), - ); - }, childCount: salesData.dailySales.length), - ), - - // Bottom Padding - const SliverToBoxAdapter(child: SpaceHeight(32)), - ], + // Bottom Padding + const SliverToBoxAdapter(child: SpaceHeight(32)), + ], + ); + }, ), ); } @@ -509,7 +446,7 @@ class _SalesPageState extends State with TickerProviderStateMixin { ); } - Widget _buildDailySalesItem(DailySales dailySale) { + Widget _buildDailySalesItem(SalesAnalyticData dailySale) { return ExpansionTile( leading: Container( padding: const EdgeInsets.all(10), @@ -527,7 +464,7 @@ class _SalesPageState extends State with TickerProviderStateMixin { ), ), subtitle: Text( - formatCurrency(dailySale.sales), + dailySale.sales.currencyFormatRp, style: TextStyle( color: AppColor.success, fontWeight: FontWeight.w600, @@ -564,14 +501,14 @@ class _SalesPageState extends State with TickerProviderStateMixin { Expanded( child: _buildDetailItem( 'Tax', - formatCurrency(dailySale.tax), + dailySale.tax.currencyFormatRp, Icons.receipt, ), ), Expanded( child: _buildDetailItem( 'Discount', - formatCurrency(dailySale.discount), + dailySale.discount.currencyFormatRp, Icons.local_offer, ), ), diff --git a/lib/presentation/router/app_router.gr.dart b/lib/presentation/router/app_router.gr.dart index f7fd053..e33909a 100644 --- a/lib/presentation/router/app_router.gr.dart +++ b/lib/presentation/router/app_router.gr.dart @@ -198,7 +198,7 @@ class ProfileRoute extends _i17.PageRouteInfo { static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { - return const _i10.ProfilePage(); + return _i17.WrappedRoute(child: const _i10.ProfilePage()); }, ); } @@ -246,7 +246,7 @@ class SalesRoute extends _i17.PageRouteInfo { static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { - return const _i13.SalesPage(); + return _i17.WrappedRoute(child: const _i13.SalesPage()); }, ); } diff --git a/pubspec.lock b/pubspec.lock index c9f4571..711d296 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1045,6 +1045,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" + shimmer: + dependency: "direct main" + description: + name: shimmer + sha256: "5f88c883a22e9f9f299e5ba0e4f7e6054857224976a5d9f839d4ebdc94a14ac9" + url: "https://pub.dev" + source: hosted + version: "3.0.0" simple_gesture_detector: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index c3e9f7f..206a197 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,6 +40,7 @@ dependencies: table_calendar: ^3.2.0 package_info_plus: ^8.3.1 loader_overlay: ^5.0.0 + shimmer: ^3.0.0 dev_dependencies: flutter_test: