diff --git a/lib/common/url/api_path.dart b/lib/common/url/api_path.dart index 9d510ac..dc970fb 100644 --- a/lib/common/url/api_path.dart +++ b/lib/common/url/api_path.dart @@ -6,6 +6,7 @@ class ApiPath { // Analytic static const String salesAnalytic = '/api/v1/analytics/sales'; static const String profitLossAnalytic = '/api/v1/analytics/profit-loss'; + static const String categoryAnalytic = '/api/v1/analytics/categories'; // Category static const String category = '/api/v1/categories'; diff --git a/lib/domain/analytic/analytic.dart b/lib/domain/analytic/analytic.dart index 0a045d0..8933596 100644 --- a/lib/domain/analytic/analytic.dart +++ b/lib/domain/analytic/analytic.dart @@ -5,5 +5,6 @@ import '../../common/api/api_failure.dart'; part 'analytic.freezed.dart'; part 'entities/sales_analytic_entity.dart'; -part 'failures/analytic_failure.dart'; part 'entities/profit_loss_analytic_entity.dart'; +part 'entities/category_analytic_entity.dart'; +part 'failures/analytic_failure.dart'; diff --git a/lib/domain/analytic/analytic.freezed.dart b/lib/domain/analytic/analytic.freezed.dart index 14c924b..0291711 100644 --- a/lib/domain/analytic/analytic.freezed.dart +++ b/lib/domain/analytic/analytic.freezed.dart @@ -876,639 +876,6 @@ abstract class _SalesAnalyticData implements SalesAnalyticData { 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; -} - /// @nodoc mixin _$ProfitLossAnalytic { String get organizationId => throw _privateConstructorUsedError; @@ -2928,3 +2295,1143 @@ abstract class _ProfitLossProductData implements ProfitLossProductData { _$$ProfitLossProductDataImplCopyWith<_$ProfitLossProductDataImpl> get copyWith => throw _privateConstructorUsedError; } + +/// @nodoc +mixin _$CategoryAnalytic { + String get organizationId => throw _privateConstructorUsedError; + String get outletId => throw _privateConstructorUsedError; + String get dateFrom => throw _privateConstructorUsedError; + String get dateTo => throw _privateConstructorUsedError; + List get data => throw _privateConstructorUsedError; + + /// Create a copy of CategoryAnalytic + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $CategoryAnalyticCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CategoryAnalyticCopyWith<$Res> { + factory $CategoryAnalyticCopyWith( + CategoryAnalytic value, + $Res Function(CategoryAnalytic) then, + ) = _$CategoryAnalyticCopyWithImpl<$Res, CategoryAnalytic>; + @useResult + $Res call({ + String organizationId, + String outletId, + String dateFrom, + String dateTo, + List data, + }); +} + +/// @nodoc +class _$CategoryAnalyticCopyWithImpl<$Res, $Val extends CategoryAnalytic> + implements $CategoryAnalyticCopyWith<$Res> { + _$CategoryAnalyticCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of CategoryAnalytic + /// 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? 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 String, + dateTo: null == dateTo + ? _value.dateTo + : dateTo // ignore: cast_nullable_to_non_nullable + as String, + data: null == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as List, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$CategoryAnalyticImplCopyWith<$Res> + implements $CategoryAnalyticCopyWith<$Res> { + factory _$$CategoryAnalyticImplCopyWith( + _$CategoryAnalyticImpl value, + $Res Function(_$CategoryAnalyticImpl) then, + ) = __$$CategoryAnalyticImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String organizationId, + String outletId, + String dateFrom, + String dateTo, + List data, + }); +} + +/// @nodoc +class __$$CategoryAnalyticImplCopyWithImpl<$Res> + extends _$CategoryAnalyticCopyWithImpl<$Res, _$CategoryAnalyticImpl> + implements _$$CategoryAnalyticImplCopyWith<$Res> { + __$$CategoryAnalyticImplCopyWithImpl( + _$CategoryAnalyticImpl _value, + $Res Function(_$CategoryAnalyticImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CategoryAnalytic + /// 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? data = null, + }) { + return _then( + _$CategoryAnalyticImpl( + 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 String, + dateTo: null == dateTo + ? _value.dateTo + : dateTo // ignore: cast_nullable_to_non_nullable + as String, + data: null == data + ? _value._data + : data // ignore: cast_nullable_to_non_nullable + as List, + ), + ); + } +} + +/// @nodoc + +class _$CategoryAnalyticImpl implements _CategoryAnalytic { + const _$CategoryAnalyticImpl({ + required this.organizationId, + required this.outletId, + required this.dateFrom, + required this.dateTo, + required final List data, + }) : _data = data; + + @override + final String organizationId; + @override + final String outletId; + @override + final String dateFrom; + @override + final String dateTo; + final List _data; + @override + List get data { + if (_data is EqualUnmodifiableListView) return _data; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_data); + } + + @override + String toString() { + return 'CategoryAnalytic(organizationId: $organizationId, outletId: $outletId, dateFrom: $dateFrom, dateTo: $dateTo, data: $data)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CategoryAnalyticImpl && + (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) && + const DeepCollectionEquality().equals(other._data, _data)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + organizationId, + outletId, + dateFrom, + dateTo, + const DeepCollectionEquality().hash(_data), + ); + + /// Create a copy of CategoryAnalytic + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CategoryAnalyticImplCopyWith<_$CategoryAnalyticImpl> get copyWith => + __$$CategoryAnalyticImplCopyWithImpl<_$CategoryAnalyticImpl>( + this, + _$identity, + ); +} + +abstract class _CategoryAnalytic implements CategoryAnalytic { + const factory _CategoryAnalytic({ + required final String organizationId, + required final String outletId, + required final String dateFrom, + required final String dateTo, + required final List data, + }) = _$CategoryAnalyticImpl; + + @override + String get organizationId; + @override + String get outletId; + @override + String get dateFrom; + @override + String get dateTo; + @override + List get data; + + /// Create a copy of CategoryAnalytic + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CategoryAnalyticImplCopyWith<_$CategoryAnalyticImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$CategoryAnalyticItem { + String get categoryId => throw _privateConstructorUsedError; + String get categoryName => throw _privateConstructorUsedError; + int get totalRevenue => throw _privateConstructorUsedError; + int get totalQuantity => throw _privateConstructorUsedError; + int get productCount => throw _privateConstructorUsedError; + int get orderCount => throw _privateConstructorUsedError; + + /// Create a copy of CategoryAnalyticItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $CategoryAnalyticItemCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CategoryAnalyticItemCopyWith<$Res> { + factory $CategoryAnalyticItemCopyWith( + CategoryAnalyticItem value, + $Res Function(CategoryAnalyticItem) then, + ) = _$CategoryAnalyticItemCopyWithImpl<$Res, CategoryAnalyticItem>; + @useResult + $Res call({ + String categoryId, + String categoryName, + int totalRevenue, + int totalQuantity, + int productCount, + int orderCount, + }); +} + +/// @nodoc +class _$CategoryAnalyticItemCopyWithImpl< + $Res, + $Val extends CategoryAnalyticItem +> + implements $CategoryAnalyticItemCopyWith<$Res> { + _$CategoryAnalyticItemCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of CategoryAnalyticItem + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? categoryId = null, + Object? categoryName = null, + Object? totalRevenue = null, + Object? totalQuantity = null, + Object? productCount = null, + Object? orderCount = null, + }) { + return _then( + _value.copyWith( + categoryId: null == categoryId + ? _value.categoryId + : categoryId // ignore: cast_nullable_to_non_nullable + as String, + categoryName: null == categoryName + ? _value.categoryName + : categoryName // ignore: cast_nullable_to_non_nullable + as String, + totalRevenue: null == totalRevenue + ? _value.totalRevenue + : totalRevenue // ignore: cast_nullable_to_non_nullable + as int, + totalQuantity: null == totalQuantity + ? _value.totalQuantity + : totalQuantity // ignore: cast_nullable_to_non_nullable + as int, + productCount: null == productCount + ? _value.productCount + : productCount // ignore: cast_nullable_to_non_nullable + as int, + orderCount: null == orderCount + ? _value.orderCount + : orderCount // ignore: cast_nullable_to_non_nullable + as int, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$CategoryAnalyticItemImplCopyWith<$Res> + implements $CategoryAnalyticItemCopyWith<$Res> { + factory _$$CategoryAnalyticItemImplCopyWith( + _$CategoryAnalyticItemImpl value, + $Res Function(_$CategoryAnalyticItemImpl) then, + ) = __$$CategoryAnalyticItemImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String categoryId, + String categoryName, + int totalRevenue, + int totalQuantity, + int productCount, + int orderCount, + }); +} + +/// @nodoc +class __$$CategoryAnalyticItemImplCopyWithImpl<$Res> + extends _$CategoryAnalyticItemCopyWithImpl<$Res, _$CategoryAnalyticItemImpl> + implements _$$CategoryAnalyticItemImplCopyWith<$Res> { + __$$CategoryAnalyticItemImplCopyWithImpl( + _$CategoryAnalyticItemImpl _value, + $Res Function(_$CategoryAnalyticItemImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CategoryAnalyticItem + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? categoryId = null, + Object? categoryName = null, + Object? totalRevenue = null, + Object? totalQuantity = null, + Object? productCount = null, + Object? orderCount = null, + }) { + return _then( + _$CategoryAnalyticItemImpl( + categoryId: null == categoryId + ? _value.categoryId + : categoryId // ignore: cast_nullable_to_non_nullable + as String, + categoryName: null == categoryName + ? _value.categoryName + : categoryName // ignore: cast_nullable_to_non_nullable + as String, + totalRevenue: null == totalRevenue + ? _value.totalRevenue + : totalRevenue // ignore: cast_nullable_to_non_nullable + as int, + totalQuantity: null == totalQuantity + ? _value.totalQuantity + : totalQuantity // ignore: cast_nullable_to_non_nullable + as int, + productCount: null == productCount + ? _value.productCount + : productCount // ignore: cast_nullable_to_non_nullable + as int, + orderCount: null == orderCount + ? _value.orderCount + : orderCount // ignore: cast_nullable_to_non_nullable + as int, + ), + ); + } +} + +/// @nodoc + +class _$CategoryAnalyticItemImpl implements _CategoryAnalyticItem { + const _$CategoryAnalyticItemImpl({ + required this.categoryId, + required this.categoryName, + required this.totalRevenue, + required this.totalQuantity, + required this.productCount, + required this.orderCount, + }); + + @override + final String categoryId; + @override + final String categoryName; + @override + final int totalRevenue; + @override + final int totalQuantity; + @override + final int productCount; + @override + final int orderCount; + + @override + String toString() { + return 'CategoryAnalyticItem(categoryId: $categoryId, categoryName: $categoryName, totalRevenue: $totalRevenue, totalQuantity: $totalQuantity, productCount: $productCount, orderCount: $orderCount)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CategoryAnalyticItemImpl && + (identical(other.categoryId, categoryId) || + other.categoryId == categoryId) && + (identical(other.categoryName, categoryName) || + other.categoryName == categoryName) && + (identical(other.totalRevenue, totalRevenue) || + other.totalRevenue == totalRevenue) && + (identical(other.totalQuantity, totalQuantity) || + other.totalQuantity == totalQuantity) && + (identical(other.productCount, productCount) || + other.productCount == productCount) && + (identical(other.orderCount, orderCount) || + other.orderCount == orderCount)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + categoryId, + categoryName, + totalRevenue, + totalQuantity, + productCount, + orderCount, + ); + + /// Create a copy of CategoryAnalyticItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CategoryAnalyticItemImplCopyWith<_$CategoryAnalyticItemImpl> + get copyWith => + __$$CategoryAnalyticItemImplCopyWithImpl<_$CategoryAnalyticItemImpl>( + this, + _$identity, + ); +} + +abstract class _CategoryAnalyticItem implements CategoryAnalyticItem { + const factory _CategoryAnalyticItem({ + required final String categoryId, + required final String categoryName, + required final int totalRevenue, + required final int totalQuantity, + required final int productCount, + required final int orderCount, + }) = _$CategoryAnalyticItemImpl; + + @override + String get categoryId; + @override + String get categoryName; + @override + int get totalRevenue; + @override + int get totalQuantity; + @override + int get productCount; + @override + int get orderCount; + + /// Create a copy of CategoryAnalyticItem + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CategoryAnalyticItemImplCopyWith<_$CategoryAnalyticItemImpl> + 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/category_analytic_entity.dart b/lib/domain/analytic/entities/category_analytic_entity.dart new file mode 100644 index 0000000..56d8f29 --- /dev/null +++ b/lib/domain/analytic/entities/category_analytic_entity.dart @@ -0,0 +1,41 @@ +part of '../analytic.dart'; + +@freezed +class CategoryAnalytic with _$CategoryAnalytic { + const factory CategoryAnalytic({ + required String organizationId, + required String outletId, + required String dateFrom, + required String dateTo, + required List data, + }) = _CategoryAnalytic; + + factory CategoryAnalytic.empty() => const CategoryAnalytic( + organizationId: "", + outletId: "", + dateFrom: "", + dateTo: "", + data: [], + ); +} + +@freezed +class CategoryAnalyticItem with _$CategoryAnalyticItem { + const factory CategoryAnalyticItem({ + required String categoryId, + required String categoryName, + required int totalRevenue, + required int totalQuantity, + required int productCount, + required int orderCount, + }) = _CategoryAnalyticItem; + + factory CategoryAnalyticItem.empty() => const CategoryAnalyticItem( + categoryId: "", + categoryName: "", + totalRevenue: 0, + totalQuantity: 0, + productCount: 0, + orderCount: 0, + ); +} diff --git a/lib/domain/analytic/repositories/i_analytic_repository.dart b/lib/domain/analytic/repositories/i_analytic_repository.dart index 95dfd2b..cb7826a 100644 --- a/lib/domain/analytic/repositories/i_analytic_repository.dart +++ b/lib/domain/analytic/repositories/i_analytic_repository.dart @@ -7,8 +7,14 @@ abstract class IAnalyticRepository { required DateTime dateFrom, required DateTime dateTo, }); + Future> getProfitLoss({ required DateTime dateFrom, required DateTime dateTo, }); + + Future> getCategory({ + required DateTime dateFrom, + required DateTime dateTo, + }); } diff --git a/lib/infrastructure/analytic/analytic_dtos.dart b/lib/infrastructure/analytic/analytic_dtos.dart index 94a2ac3..a812a02 100644 --- a/lib/infrastructure/analytic/analytic_dtos.dart +++ b/lib/infrastructure/analytic/analytic_dtos.dart @@ -7,3 +7,4 @@ part 'analytic_dtos.g.dart'; part 'dto/sales_analytic_dto.dart'; part 'dto/profit_loss_analytic_dto.dart'; +part 'dto/category_analytic_dto.dart'; diff --git a/lib/infrastructure/analytic/analytic_dtos.freezed.dart b/lib/infrastructure/analytic/analytic_dtos.freezed.dart index 4d03fe3..eee2978 100644 --- a/lib/infrastructure/analytic/analytic_dtos.freezed.dart +++ b/lib/infrastructure/analytic/analytic_dtos.freezed.dart @@ -2670,3 +2670,591 @@ abstract class _ProfitLossProductDataDto extends ProfitLossProductDataDto { _$$ProfitLossProductDataDtoImplCopyWith<_$ProfitLossProductDataDtoImpl> get copyWith => throw _privateConstructorUsedError; } + +CategoryAnalyticDto _$CategoryAnalyticDtoFromJson(Map json) { + return _CategoryAnalyticDto.fromJson(json); +} + +/// @nodoc +mixin _$CategoryAnalyticDto { + @JsonKey(name: 'organization_id') + String? get organizationId => throw _privateConstructorUsedError; + @JsonKey(name: 'outlet_id') + String? get outletId => throw _privateConstructorUsedError; + @JsonKey(name: 'date_from') + String? get dateFrom => throw _privateConstructorUsedError; + @JsonKey(name: 'date_to') + String? get dateTo => throw _privateConstructorUsedError; + @JsonKey(name: 'data') + List? get data => throw _privateConstructorUsedError; + + /// Serializes this CategoryAnalyticDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of CategoryAnalyticDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $CategoryAnalyticDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CategoryAnalyticDtoCopyWith<$Res> { + factory $CategoryAnalyticDtoCopyWith( + CategoryAnalyticDto value, + $Res Function(CategoryAnalyticDto) then, + ) = _$CategoryAnalyticDtoCopyWithImpl<$Res, CategoryAnalyticDto>; + @useResult + $Res call({ + @JsonKey(name: 'organization_id') String? organizationId, + @JsonKey(name: 'outlet_id') String? outletId, + @JsonKey(name: 'date_from') String? dateFrom, + @JsonKey(name: 'date_to') String? dateTo, + @JsonKey(name: 'data') List? data, + }); +} + +/// @nodoc +class _$CategoryAnalyticDtoCopyWithImpl<$Res, $Val extends CategoryAnalyticDto> + implements $CategoryAnalyticDtoCopyWith<$Res> { + _$CategoryAnalyticDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of CategoryAnalyticDto + /// 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? 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 String?, + dateTo: freezed == dateTo + ? _value.dateTo + : dateTo // ignore: cast_nullable_to_non_nullable + as String?, + data: freezed == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as List?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$CategoryAnalyticDtoImplCopyWith<$Res> + implements $CategoryAnalyticDtoCopyWith<$Res> { + factory _$$CategoryAnalyticDtoImplCopyWith( + _$CategoryAnalyticDtoImpl value, + $Res Function(_$CategoryAnalyticDtoImpl) then, + ) = __$$CategoryAnalyticDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: 'organization_id') String? organizationId, + @JsonKey(name: 'outlet_id') String? outletId, + @JsonKey(name: 'date_from') String? dateFrom, + @JsonKey(name: 'date_to') String? dateTo, + @JsonKey(name: 'data') List? data, + }); +} + +/// @nodoc +class __$$CategoryAnalyticDtoImplCopyWithImpl<$Res> + extends _$CategoryAnalyticDtoCopyWithImpl<$Res, _$CategoryAnalyticDtoImpl> + implements _$$CategoryAnalyticDtoImplCopyWith<$Res> { + __$$CategoryAnalyticDtoImplCopyWithImpl( + _$CategoryAnalyticDtoImpl _value, + $Res Function(_$CategoryAnalyticDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CategoryAnalyticDto + /// 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? data = freezed, + }) { + return _then( + _$CategoryAnalyticDtoImpl( + 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 String?, + dateTo: freezed == dateTo + ? _value.dateTo + : dateTo // ignore: cast_nullable_to_non_nullable + as String?, + data: freezed == data + ? _value._data + : data // ignore: cast_nullable_to_non_nullable + as List?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$CategoryAnalyticDtoImpl extends _CategoryAnalyticDto { + const _$CategoryAnalyticDtoImpl({ + @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: 'data') final List? data, + }) : _data = data, + super._(); + + factory _$CategoryAnalyticDtoImpl.fromJson(Map json) => + _$$CategoryAnalyticDtoImplFromJson(json); + + @override + @JsonKey(name: 'organization_id') + final String? organizationId; + @override + @JsonKey(name: 'outlet_id') + final String? outletId; + @override + @JsonKey(name: 'date_from') + final String? dateFrom; + @override + @JsonKey(name: 'date_to') + final String? dateTo; + 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 'CategoryAnalyticDto(organizationId: $organizationId, outletId: $outletId, dateFrom: $dateFrom, dateTo: $dateTo, data: $data)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CategoryAnalyticDtoImpl && + (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) && + const DeepCollectionEquality().equals(other._data, _data)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + organizationId, + outletId, + dateFrom, + dateTo, + const DeepCollectionEquality().hash(_data), + ); + + /// Create a copy of CategoryAnalyticDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CategoryAnalyticDtoImplCopyWith<_$CategoryAnalyticDtoImpl> get copyWith => + __$$CategoryAnalyticDtoImplCopyWithImpl<_$CategoryAnalyticDtoImpl>( + this, + _$identity, + ); + + @override + Map toJson() { + return _$$CategoryAnalyticDtoImplToJson(this); + } +} + +abstract class _CategoryAnalyticDto extends CategoryAnalyticDto { + const factory _CategoryAnalyticDto({ + @JsonKey(name: 'organization_id') final String? organizationId, + @JsonKey(name: 'outlet_id') final String? outletId, + @JsonKey(name: 'date_from') final String? dateFrom, + @JsonKey(name: 'date_to') final String? dateTo, + @JsonKey(name: 'data') final List? data, + }) = _$CategoryAnalyticDtoImpl; + const _CategoryAnalyticDto._() : super._(); + + factory _CategoryAnalyticDto.fromJson(Map json) = + _$CategoryAnalyticDtoImpl.fromJson; + + @override + @JsonKey(name: 'organization_id') + String? get organizationId; + @override + @JsonKey(name: 'outlet_id') + String? get outletId; + @override + @JsonKey(name: 'date_from') + String? get dateFrom; + @override + @JsonKey(name: 'date_to') + String? get dateTo; + @override + @JsonKey(name: 'data') + List? get data; + + /// Create a copy of CategoryAnalyticDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CategoryAnalyticDtoImplCopyWith<_$CategoryAnalyticDtoImpl> get copyWith => + throw _privateConstructorUsedError; +} + +CategoryAnalyticItemDto _$CategoryAnalyticItemDtoFromJson( + Map json, +) { + return _CategoryAnalyticItemDto.fromJson(json); +} + +/// @nodoc +mixin _$CategoryAnalyticItemDto { + @JsonKey(name: 'category_id') + String? get categoryId => throw _privateConstructorUsedError; + @JsonKey(name: 'category_name') + String? get categoryName => throw _privateConstructorUsedError; + @JsonKey(name: 'total_revenue') + int? get totalRevenue => throw _privateConstructorUsedError; + @JsonKey(name: 'total_quantity') + int? get totalQuantity => throw _privateConstructorUsedError; + @JsonKey(name: 'product_count') + int? get productCount => throw _privateConstructorUsedError; + @JsonKey(name: 'order_count') + int? get orderCount => throw _privateConstructorUsedError; + + /// Serializes this CategoryAnalyticItemDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of CategoryAnalyticItemDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $CategoryAnalyticItemDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CategoryAnalyticItemDtoCopyWith<$Res> { + factory $CategoryAnalyticItemDtoCopyWith( + CategoryAnalyticItemDto value, + $Res Function(CategoryAnalyticItemDto) then, + ) = _$CategoryAnalyticItemDtoCopyWithImpl<$Res, CategoryAnalyticItemDto>; + @useResult + $Res call({ + @JsonKey(name: 'category_id') String? categoryId, + @JsonKey(name: 'category_name') String? categoryName, + @JsonKey(name: 'total_revenue') int? totalRevenue, + @JsonKey(name: 'total_quantity') int? totalQuantity, + @JsonKey(name: 'product_count') int? productCount, + @JsonKey(name: 'order_count') int? orderCount, + }); +} + +/// @nodoc +class _$CategoryAnalyticItemDtoCopyWithImpl< + $Res, + $Val extends CategoryAnalyticItemDto +> + implements $CategoryAnalyticItemDtoCopyWith<$Res> { + _$CategoryAnalyticItemDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of CategoryAnalyticItemDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? categoryId = freezed, + Object? categoryName = freezed, + Object? totalRevenue = freezed, + Object? totalQuantity = freezed, + Object? productCount = freezed, + Object? orderCount = freezed, + }) { + return _then( + _value.copyWith( + categoryId: freezed == categoryId + ? _value.categoryId + : categoryId // ignore: cast_nullable_to_non_nullable + as String?, + categoryName: freezed == categoryName + ? _value.categoryName + : categoryName // ignore: cast_nullable_to_non_nullable + as String?, + totalRevenue: freezed == totalRevenue + ? _value.totalRevenue + : totalRevenue // ignore: cast_nullable_to_non_nullable + as int?, + totalQuantity: freezed == totalQuantity + ? _value.totalQuantity + : totalQuantity // ignore: cast_nullable_to_non_nullable + as int?, + productCount: freezed == productCount + ? _value.productCount + : productCount // ignore: cast_nullable_to_non_nullable + as int?, + orderCount: freezed == orderCount + ? _value.orderCount + : orderCount // ignore: cast_nullable_to_non_nullable + as int?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$CategoryAnalyticItemDtoImplCopyWith<$Res> + implements $CategoryAnalyticItemDtoCopyWith<$Res> { + factory _$$CategoryAnalyticItemDtoImplCopyWith( + _$CategoryAnalyticItemDtoImpl value, + $Res Function(_$CategoryAnalyticItemDtoImpl) then, + ) = __$$CategoryAnalyticItemDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: 'category_id') String? categoryId, + @JsonKey(name: 'category_name') String? categoryName, + @JsonKey(name: 'total_revenue') int? totalRevenue, + @JsonKey(name: 'total_quantity') int? totalQuantity, + @JsonKey(name: 'product_count') int? productCount, + @JsonKey(name: 'order_count') int? orderCount, + }); +} + +/// @nodoc +class __$$CategoryAnalyticItemDtoImplCopyWithImpl<$Res> + extends + _$CategoryAnalyticItemDtoCopyWithImpl< + $Res, + _$CategoryAnalyticItemDtoImpl + > + implements _$$CategoryAnalyticItemDtoImplCopyWith<$Res> { + __$$CategoryAnalyticItemDtoImplCopyWithImpl( + _$CategoryAnalyticItemDtoImpl _value, + $Res Function(_$CategoryAnalyticItemDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CategoryAnalyticItemDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? categoryId = freezed, + Object? categoryName = freezed, + Object? totalRevenue = freezed, + Object? totalQuantity = freezed, + Object? productCount = freezed, + Object? orderCount = freezed, + }) { + return _then( + _$CategoryAnalyticItemDtoImpl( + categoryId: freezed == categoryId + ? _value.categoryId + : categoryId // ignore: cast_nullable_to_non_nullable + as String?, + categoryName: freezed == categoryName + ? _value.categoryName + : categoryName // ignore: cast_nullable_to_non_nullable + as String?, + totalRevenue: freezed == totalRevenue + ? _value.totalRevenue + : totalRevenue // ignore: cast_nullable_to_non_nullable + as int?, + totalQuantity: freezed == totalQuantity + ? _value.totalQuantity + : totalQuantity // ignore: cast_nullable_to_non_nullable + as int?, + productCount: freezed == productCount + ? _value.productCount + : productCount // ignore: cast_nullable_to_non_nullable + as int?, + orderCount: freezed == orderCount + ? _value.orderCount + : orderCount // ignore: cast_nullable_to_non_nullable + as int?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$CategoryAnalyticItemDtoImpl extends _CategoryAnalyticItemDto { + const _$CategoryAnalyticItemDtoImpl({ + @JsonKey(name: 'category_id') this.categoryId, + @JsonKey(name: 'category_name') this.categoryName, + @JsonKey(name: 'total_revenue') this.totalRevenue, + @JsonKey(name: 'total_quantity') this.totalQuantity, + @JsonKey(name: 'product_count') this.productCount, + @JsonKey(name: 'order_count') this.orderCount, + }) : super._(); + + factory _$CategoryAnalyticItemDtoImpl.fromJson(Map json) => + _$$CategoryAnalyticItemDtoImplFromJson(json); + + @override + @JsonKey(name: 'category_id') + final String? categoryId; + @override + @JsonKey(name: 'category_name') + final String? categoryName; + @override + @JsonKey(name: 'total_revenue') + final int? totalRevenue; + @override + @JsonKey(name: 'total_quantity') + final int? totalQuantity; + @override + @JsonKey(name: 'product_count') + final int? productCount; + @override + @JsonKey(name: 'order_count') + final int? orderCount; + + @override + String toString() { + return 'CategoryAnalyticItemDto(categoryId: $categoryId, categoryName: $categoryName, totalRevenue: $totalRevenue, totalQuantity: $totalQuantity, productCount: $productCount, orderCount: $orderCount)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CategoryAnalyticItemDtoImpl && + (identical(other.categoryId, categoryId) || + other.categoryId == categoryId) && + (identical(other.categoryName, categoryName) || + other.categoryName == categoryName) && + (identical(other.totalRevenue, totalRevenue) || + other.totalRevenue == totalRevenue) && + (identical(other.totalQuantity, totalQuantity) || + other.totalQuantity == totalQuantity) && + (identical(other.productCount, productCount) || + other.productCount == productCount) && + (identical(other.orderCount, orderCount) || + other.orderCount == orderCount)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + categoryId, + categoryName, + totalRevenue, + totalQuantity, + productCount, + orderCount, + ); + + /// Create a copy of CategoryAnalyticItemDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CategoryAnalyticItemDtoImplCopyWith<_$CategoryAnalyticItemDtoImpl> + get copyWith => + __$$CategoryAnalyticItemDtoImplCopyWithImpl< + _$CategoryAnalyticItemDtoImpl + >(this, _$identity); + + @override + Map toJson() { + return _$$CategoryAnalyticItemDtoImplToJson(this); + } +} + +abstract class _CategoryAnalyticItemDto extends CategoryAnalyticItemDto { + const factory _CategoryAnalyticItemDto({ + @JsonKey(name: 'category_id') final String? categoryId, + @JsonKey(name: 'category_name') final String? categoryName, + @JsonKey(name: 'total_revenue') final int? totalRevenue, + @JsonKey(name: 'total_quantity') final int? totalQuantity, + @JsonKey(name: 'product_count') final int? productCount, + @JsonKey(name: 'order_count') final int? orderCount, + }) = _$CategoryAnalyticItemDtoImpl; + const _CategoryAnalyticItemDto._() : super._(); + + factory _CategoryAnalyticItemDto.fromJson(Map json) = + _$CategoryAnalyticItemDtoImpl.fromJson; + + @override + @JsonKey(name: 'category_id') + String? get categoryId; + @override + @JsonKey(name: 'category_name') + String? get categoryName; + @override + @JsonKey(name: 'total_revenue') + int? get totalRevenue; + @override + @JsonKey(name: 'total_quantity') + int? get totalQuantity; + @override + @JsonKey(name: 'product_count') + int? get productCount; + @override + @JsonKey(name: 'order_count') + int? get orderCount; + + /// Create a copy of CategoryAnalyticItemDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CategoryAnalyticItemDtoImplCopyWith<_$CategoryAnalyticItemDtoImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/infrastructure/analytic/analytic_dtos.g.dart b/lib/infrastructure/analytic/analytic_dtos.g.dart index 2ffcf80..044d525 100644 --- a/lib/infrastructure/analytic/analytic_dtos.g.dart +++ b/lib/infrastructure/analytic/analytic_dtos.g.dart @@ -213,3 +213,47 @@ Map _$$ProfitLossProductDataDtoImplToJson( 'average_cost': instance.averageCost, 'profit_per_unit': instance.profitPerUnit, }; + +_$CategoryAnalyticDtoImpl _$$CategoryAnalyticDtoImplFromJson( + Map json, +) => _$CategoryAnalyticDtoImpl( + organizationId: json['organization_id'] as String?, + outletId: json['outlet_id'] as String?, + dateFrom: json['date_from'] as String?, + dateTo: json['date_to'] as String?, + data: (json['data'] as List?) + ?.map((e) => CategoryAnalyticItemDto.fromJson(e as Map)) + .toList(), +); + +Map _$$CategoryAnalyticDtoImplToJson( + _$CategoryAnalyticDtoImpl instance, +) => { + 'organization_id': instance.organizationId, + 'outlet_id': instance.outletId, + 'date_from': instance.dateFrom, + 'date_to': instance.dateTo, + 'data': instance.data, +}; + +_$CategoryAnalyticItemDtoImpl _$$CategoryAnalyticItemDtoImplFromJson( + Map json, +) => _$CategoryAnalyticItemDtoImpl( + categoryId: json['category_id'] as String?, + categoryName: json['category_name'] as String?, + totalRevenue: (json['total_revenue'] as num?)?.toInt(), + totalQuantity: (json['total_quantity'] as num?)?.toInt(), + productCount: (json['product_count'] as num?)?.toInt(), + orderCount: (json['order_count'] as num?)?.toInt(), +); + +Map _$$CategoryAnalyticItemDtoImplToJson( + _$CategoryAnalyticItemDtoImpl instance, +) => { + 'category_id': instance.categoryId, + 'category_name': instance.categoryName, + 'total_revenue': instance.totalRevenue, + 'total_quantity': instance.totalQuantity, + 'product_count': instance.productCount, + 'order_count': instance.orderCount, +}; diff --git a/lib/infrastructure/analytic/datasource/remote_data_provider.dart b/lib/infrastructure/analytic/datasource/remote_data_provider.dart index 91c1d26..ec9253b 100644 --- a/lib/infrastructure/analytic/datasource/remote_data_provider.dart +++ b/lib/infrastructure/analytic/datasource/remote_data_provider.dart @@ -71,4 +71,31 @@ class AnalyticRemoteDataProvider { return DC.error(AnalyticFailure.serverError(e)); } } + + Future> fetchCategory({ + required DateTime dateFrom, + required DateTime dateTo, + }) async { + try { + final response = await _apiClient.get( + ApiPath.category, + params: { + 'date_from': dateFrom.toServerDate, + 'date_to': dateTo.toServerDate, + }, + headers: getAuthorizationHeader(), + ); + + if (response.data['data'] == null) { + return DC.error(AnalyticFailure.empty()); + } + + final dto = CategoryAnalyticDto.fromJson(response.data['data']); + + return DC.data(dto); + } on ApiFailure catch (e, s) { + log('fetchCategoryError', name: _logName, error: e, stackTrace: s); + return DC.error(AnalyticFailure.serverError(e)); + } + } } diff --git a/lib/infrastructure/analytic/dto/category_analytic_dto.dart b/lib/infrastructure/analytic/dto/category_analytic_dto.dart new file mode 100644 index 0000000..55c43ce --- /dev/null +++ b/lib/infrastructure/analytic/dto/category_analytic_dto.dart @@ -0,0 +1,51 @@ +part of '../analytic_dtos.dart'; + +@freezed +class CategoryAnalyticDto with _$CategoryAnalyticDto { + const CategoryAnalyticDto._(); + + const factory CategoryAnalyticDto({ + @JsonKey(name: 'organization_id') String? organizationId, + @JsonKey(name: 'outlet_id') String? outletId, + @JsonKey(name: 'date_from') String? dateFrom, + @JsonKey(name: 'date_to') String? dateTo, + @JsonKey(name: 'data') List? data, + }) = _CategoryAnalyticDto; + + factory CategoryAnalyticDto.fromJson(Map json) => + _$CategoryAnalyticDtoFromJson(json); + + CategoryAnalytic toDomain() => CategoryAnalytic( + organizationId: organizationId ?? "", + outletId: outletId ?? "", + dateFrom: dateFrom ?? "", + dateTo: dateTo ?? "", + data: data?.map((e) => e.toDomain()).toList() ?? [], + ); +} + +@freezed +class CategoryAnalyticItemDto with _$CategoryAnalyticItemDto { + const CategoryAnalyticItemDto._(); + + const factory CategoryAnalyticItemDto({ + @JsonKey(name: 'category_id') String? categoryId, + @JsonKey(name: 'category_name') String? categoryName, + @JsonKey(name: 'total_revenue') int? totalRevenue, + @JsonKey(name: 'total_quantity') int? totalQuantity, + @JsonKey(name: 'product_count') int? productCount, + @JsonKey(name: 'order_count') int? orderCount, + }) = _CategoryAnalyticItemDto; + + factory CategoryAnalyticItemDto.fromJson(Map json) => + _$CategoryAnalyticItemDtoFromJson(json); + + CategoryAnalyticItem toDomain() => CategoryAnalyticItem( + categoryId: categoryId ?? "", + categoryName: categoryName ?? "", + totalRevenue: totalRevenue ?? 0, + totalQuantity: totalQuantity ?? 0, + productCount: productCount ?? 0, + orderCount: orderCount ?? 0, + ); +} diff --git a/lib/infrastructure/analytic/repositories/analytic_repository.dart b/lib/infrastructure/analytic/repositories/analytic_repository.dart index 5cd3412..3acc60a 100644 --- a/lib/infrastructure/analytic/repositories/analytic_repository.dart +++ b/lib/infrastructure/analytic/repositories/analytic_repository.dart @@ -61,4 +61,28 @@ class AnalyticRepository implements IAnalyticRepository { return left(const AnalyticFailure.unexpectedError()); } } + + @override + Future> getCategory({ + required DateTime dateFrom, + required DateTime dateTo, + }) async { + try { + final result = await _dataProvider.fetchCategory( + dateFrom: dateFrom, + dateTo: dateTo, + ); + + if (result.hasError) { + return left(result.error!); + } + + final auth = result.data!.toDomain(); + + return right(auth); + } catch (e, s) { + log('getCategoryError', name: _logName, error: e, stackTrace: s); + return left(const AnalyticFailure.unexpectedError()); + } + } } diff --git a/lib/injection.config.dart b/lib/injection.config.dart index aec6edc..912a8d1 100644 --- a/lib/injection.config.dart +++ b/lib/injection.config.dart @@ -136,15 +136,15 @@ extension GetItInjectableX on _i174.GetIt { gh.factory<_i458.ProductLoaderBloc>( () => _i458.ProductLoaderBloc(gh<_i419.IProductRepository>()), ); - gh.factory<_i608.ProfitLossLoaderBloc>( - () => _i608.ProfitLossLoaderBloc(gh<_i477.IAnalyticRepository>()), - ); gh.factory<_i183.CategoryLoaderBloc>( () => _i183.CategoryLoaderBloc(gh<_i1020.ICategoryRepository>()), ); gh.factory<_i882.SalesLoaderBloc>( () => _i882.SalesLoaderBloc(gh<_i477.IAnalyticRepository>()), ); + gh.factory<_i608.ProfitLossLoaderBloc>( + () => _i608.ProfitLossLoaderBloc(gh<_i477.IAnalyticRepository>()), + ); gh.factory<_i775.LoginFormBloc>( () => _i775.LoginFormBloc(gh<_i49.IAuthRepository>()), ); diff --git a/lib/presentation/router/app_router.gr.dart b/lib/presentation/router/app_router.gr.dart index b4e4d2a..877fd96 100644 --- a/lib/presentation/router/app_router.gr.dart +++ b/lib/presentation/router/app_router.gr.dart @@ -167,7 +167,7 @@ class FinanceRoute extends _i18.PageRouteInfo { static _i18.PageInfo page = _i18.PageInfo( name, builder: (data) { - return const _i4.FinancePage(); + return _i18.WrappedRoute(child: const _i4.FinancePage()); }, ); }