diff --git a/lib/application/analytic/purchasing_analytic_loader/purchasing_analytic_loader_bloc.dart b/lib/application/analytic/purchasing_analytic_loader/purchasing_analytic_loader_bloc.dart new file mode 100644 index 0000000..4426bd9 --- /dev/null +++ b/lib/application/analytic/purchasing_analytic_loader/purchasing_analytic_loader_bloc.dart @@ -0,0 +1,54 @@ +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 'purchasing_analytic_loader_event.dart'; +part 'purchasing_analytic_loader_state.dart'; +part 'purchasing_analytic_loader_bloc.freezed.dart'; + +@injectable +class PurchasingAnalyticLoaderBloc + extends Bloc { + final IAnalyticRepository _analyticRepository; + + PurchasingAnalyticLoaderBloc(this._analyticRepository) + : super(PurchasingAnalyticLoaderState.initial()) { + on(_onEvent); + } + + Future _onEvent( + PurchasingAnalyticLoaderEvent event, + Emitter emit, + ) { + return event.map( + rangeDateChanged: (e) async { + emit(state.copyWith(dateFrom: e.dateFrom, dateTo: e.dateTo)); + }, + fetched: (e) async { + emit( + state.copyWith( + isFetching: true, + failureOptionPurchasing: none(), + ), + ); + + final result = await _analyticRepository.getPurchasing( + dateFrom: state.dateFrom, + dateTo: state.dateTo, + ); + + final newState = result.fold( + (f) => + state.copyWith(failureOptionPurchasing: optionOf(f)), + (purchasing) => state.copyWith(purchasing: purchasing), + ); + + emit(newState.copyWith(isFetching: false)); + }, + ); + } +} diff --git a/lib/application/analytic/purchasing_analytic_loader/purchasing_analytic_loader_bloc.freezed.dart b/lib/application/analytic/purchasing_analytic_loader/purchasing_analytic_loader_bloc.freezed.dart new file mode 100644 index 0000000..66403d9 --- /dev/null +++ b/lib/application/analytic/purchasing_analytic_loader/purchasing_analytic_loader_bloc.freezed.dart @@ -0,0 +1,627 @@ +// 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 'purchasing_analytic_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 _$PurchasingAnalyticLoaderEvent { + @optionalTypeArgs + TResult when({ + required TResult Function(DateTime dateFrom, DateTime dateTo) + rangeDateChanged, + required TResult Function() fetched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, + TResult? Function()? fetched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, + TResult Function()? fetched, + required TResult orElse(), + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(_RangeDateChanged value) rangeDateChanged, + required TResult Function(_Fetched value) fetched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_RangeDateChanged value)? rangeDateChanged, + TResult? Function(_Fetched value)? fetched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_RangeDateChanged value)? rangeDateChanged, + TResult Function(_Fetched value)? fetched, + required TResult orElse(), + }) => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PurchasingAnalyticLoaderEventCopyWith<$Res> { + factory $PurchasingAnalyticLoaderEventCopyWith( + PurchasingAnalyticLoaderEvent value, + $Res Function(PurchasingAnalyticLoaderEvent) then, + ) = + _$PurchasingAnalyticLoaderEventCopyWithImpl< + $Res, + PurchasingAnalyticLoaderEvent + >; +} + +/// @nodoc +class _$PurchasingAnalyticLoaderEventCopyWithImpl< + $Res, + $Val extends PurchasingAnalyticLoaderEvent +> + implements $PurchasingAnalyticLoaderEventCopyWith<$Res> { + _$PurchasingAnalyticLoaderEventCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PurchasingAnalyticLoaderEvent + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$RangeDateChangedImplCopyWith<$Res> { + factory _$$RangeDateChangedImplCopyWith( + _$RangeDateChangedImpl value, + $Res Function(_$RangeDateChangedImpl) then, + ) = __$$RangeDateChangedImplCopyWithImpl<$Res>; + @useResult + $Res call({DateTime dateFrom, DateTime dateTo}); +} + +/// @nodoc +class __$$RangeDateChangedImplCopyWithImpl<$Res> + extends + _$PurchasingAnalyticLoaderEventCopyWithImpl< + $Res, + _$RangeDateChangedImpl + > + implements _$$RangeDateChangedImplCopyWith<$Res> { + __$$RangeDateChangedImplCopyWithImpl( + _$RangeDateChangedImpl _value, + $Res Function(_$RangeDateChangedImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PurchasingAnalyticLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? dateFrom = null, Object? dateTo = null}) { + return _then( + _$RangeDateChangedImpl( + null == dateFrom + ? _value.dateFrom + : dateFrom // ignore: cast_nullable_to_non_nullable + as DateTime, + null == dateTo + ? _value.dateTo + : dateTo // ignore: cast_nullable_to_non_nullable + as DateTime, + ), + ); + } +} + +/// @nodoc + +class _$RangeDateChangedImpl implements _RangeDateChanged { + const _$RangeDateChangedImpl(this.dateFrom, this.dateTo); + + @override + final DateTime dateFrom; + @override + final DateTime dateTo; + + @override + String toString() { + return 'PurchasingAnalyticLoaderEvent.rangeDateChanged(dateFrom: $dateFrom, dateTo: $dateTo)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RangeDateChangedImpl && + (identical(other.dateFrom, dateFrom) || + other.dateFrom == dateFrom) && + (identical(other.dateTo, dateTo) || other.dateTo == dateTo)); + } + + @override + int get hashCode => Object.hash(runtimeType, dateFrom, dateTo); + + /// Create a copy of PurchasingAnalyticLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$RangeDateChangedImplCopyWith<_$RangeDateChangedImpl> get copyWith => + __$$RangeDateChangedImplCopyWithImpl<_$RangeDateChangedImpl>( + this, + _$identity, + ); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(DateTime dateFrom, DateTime dateTo) + rangeDateChanged, + required TResult Function() fetched, + }) { + return rangeDateChanged(dateFrom, dateTo); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, + TResult? Function()? fetched, + }) { + return rangeDateChanged?.call(dateFrom, dateTo); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, + TResult Function()? fetched, + required TResult orElse(), + }) { + if (rangeDateChanged != null) { + return rangeDateChanged(dateFrom, dateTo); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_RangeDateChanged value) rangeDateChanged, + required TResult Function(_Fetched value) fetched, + }) { + return rangeDateChanged(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_RangeDateChanged value)? rangeDateChanged, + TResult? Function(_Fetched value)? fetched, + }) { + return rangeDateChanged?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_RangeDateChanged value)? rangeDateChanged, + TResult Function(_Fetched value)? fetched, + required TResult orElse(), + }) { + if (rangeDateChanged != null) { + return rangeDateChanged(this); + } + return orElse(); + } +} + +abstract class _RangeDateChanged implements PurchasingAnalyticLoaderEvent { + const factory _RangeDateChanged( + final DateTime dateFrom, + final DateTime dateTo, + ) = _$RangeDateChangedImpl; + + DateTime get dateFrom; + DateTime get dateTo; + + /// Create a copy of PurchasingAnalyticLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$RangeDateChangedImplCopyWith<_$RangeDateChangedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$FetchedImplCopyWith<$Res> { + factory _$$FetchedImplCopyWith( + _$FetchedImpl value, + $Res Function(_$FetchedImpl) then, + ) = __$$FetchedImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$FetchedImplCopyWithImpl<$Res> + extends _$PurchasingAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl> + implements _$$FetchedImplCopyWith<$Res> { + __$$FetchedImplCopyWithImpl( + _$FetchedImpl _value, + $Res Function(_$FetchedImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PurchasingAnalyticLoaderEvent + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$FetchedImpl implements _Fetched { + const _$FetchedImpl(); + + @override + String toString() { + return 'PurchasingAnalyticLoaderEvent.fetched()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$FetchedImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(DateTime dateFrom, DateTime dateTo) + rangeDateChanged, + required TResult Function() fetched, + }) { + return fetched(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, + TResult? Function()? fetched, + }) { + return fetched?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, + TResult Function()? fetched, + required TResult orElse(), + }) { + if (fetched != null) { + return fetched(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_RangeDateChanged value) rangeDateChanged, + required TResult Function(_Fetched value) fetched, + }) { + return fetched(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_RangeDateChanged value)? rangeDateChanged, + TResult? Function(_Fetched value)? fetched, + }) { + return fetched?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_RangeDateChanged value)? rangeDateChanged, + TResult Function(_Fetched value)? fetched, + required TResult orElse(), + }) { + if (fetched != null) { + return fetched(this); + } + return orElse(); + } +} + +abstract class _Fetched implements PurchasingAnalyticLoaderEvent { + const factory _Fetched() = _$FetchedImpl; +} + +/// @nodoc +mixin _$PurchasingAnalyticLoaderState { + PurchasingAnalytic get purchasing => throw _privateConstructorUsedError; + Option get failureOptionPurchasing => + throw _privateConstructorUsedError; + bool get isFetching => throw _privateConstructorUsedError; + DateTime get dateFrom => throw _privateConstructorUsedError; + DateTime get dateTo => throw _privateConstructorUsedError; + + /// Create a copy of PurchasingAnalyticLoaderState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PurchasingAnalyticLoaderStateCopyWith + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PurchasingAnalyticLoaderStateCopyWith<$Res> { + factory $PurchasingAnalyticLoaderStateCopyWith( + PurchasingAnalyticLoaderState value, + $Res Function(PurchasingAnalyticLoaderState) then, + ) = + _$PurchasingAnalyticLoaderStateCopyWithImpl< + $Res, + PurchasingAnalyticLoaderState + >; + @useResult + $Res call({ + PurchasingAnalytic purchasing, + Option failureOptionPurchasing, + bool isFetching, + DateTime dateFrom, + DateTime dateTo, + }); + + $PurchasingAnalyticCopyWith<$Res> get purchasing; +} + +/// @nodoc +class _$PurchasingAnalyticLoaderStateCopyWithImpl< + $Res, + $Val extends PurchasingAnalyticLoaderState +> + implements $PurchasingAnalyticLoaderStateCopyWith<$Res> { + _$PurchasingAnalyticLoaderStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PurchasingAnalyticLoaderState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? purchasing = null, + Object? failureOptionPurchasing = null, + Object? isFetching = null, + Object? dateFrom = null, + Object? dateTo = null, + }) { + return _then( + _value.copyWith( + purchasing: null == purchasing + ? _value.purchasing + : purchasing // ignore: cast_nullable_to_non_nullable + as PurchasingAnalytic, + failureOptionPurchasing: null == failureOptionPurchasing + ? _value.failureOptionPurchasing + : failureOptionPurchasing // ignore: cast_nullable_to_non_nullable + as Option, + isFetching: null == isFetching + ? _value.isFetching + : isFetching // ignore: cast_nullable_to_non_nullable + as bool, + 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, + ) + as $Val, + ); + } + + /// Create a copy of PurchasingAnalyticLoaderState + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $PurchasingAnalyticCopyWith<$Res> get purchasing { + return $PurchasingAnalyticCopyWith<$Res>(_value.purchasing, (value) { + return _then(_value.copyWith(purchasing: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$PurchasingAnalyticLoaderStateImplCopyWith<$Res> + implements $PurchasingAnalyticLoaderStateCopyWith<$Res> { + factory _$$PurchasingAnalyticLoaderStateImplCopyWith( + _$PurchasingAnalyticLoaderStateImpl value, + $Res Function(_$PurchasingAnalyticLoaderStateImpl) then, + ) = __$$PurchasingAnalyticLoaderStateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + PurchasingAnalytic purchasing, + Option failureOptionPurchasing, + bool isFetching, + DateTime dateFrom, + DateTime dateTo, + }); + + @override + $PurchasingAnalyticCopyWith<$Res> get purchasing; +} + +/// @nodoc +class __$$PurchasingAnalyticLoaderStateImplCopyWithImpl<$Res> + extends + _$PurchasingAnalyticLoaderStateCopyWithImpl< + $Res, + _$PurchasingAnalyticLoaderStateImpl + > + implements _$$PurchasingAnalyticLoaderStateImplCopyWith<$Res> { + __$$PurchasingAnalyticLoaderStateImplCopyWithImpl( + _$PurchasingAnalyticLoaderStateImpl _value, + $Res Function(_$PurchasingAnalyticLoaderStateImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PurchasingAnalyticLoaderState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? purchasing = null, + Object? failureOptionPurchasing = null, + Object? isFetching = null, + Object? dateFrom = null, + Object? dateTo = null, + }) { + return _then( + _$PurchasingAnalyticLoaderStateImpl( + purchasing: null == purchasing + ? _value.purchasing + : purchasing // ignore: cast_nullable_to_non_nullable + as PurchasingAnalytic, + failureOptionPurchasing: null == failureOptionPurchasing + ? _value.failureOptionPurchasing + : failureOptionPurchasing // ignore: cast_nullable_to_non_nullable + as Option, + isFetching: null == isFetching + ? _value.isFetching + : isFetching // ignore: cast_nullable_to_non_nullable + as bool, + 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, + ), + ); + } +} + +/// @nodoc + +class _$PurchasingAnalyticLoaderStateImpl + implements _PurchasingAnalyticLoaderState { + const _$PurchasingAnalyticLoaderStateImpl({ + required this.purchasing, + required this.failureOptionPurchasing, + this.isFetching = false, + required this.dateFrom, + required this.dateTo, + }); + + @override + final PurchasingAnalytic purchasing; + @override + final Option failureOptionPurchasing; + @override + @JsonKey() + final bool isFetching; + @override + final DateTime dateFrom; + @override + final DateTime dateTo; + + @override + String toString() { + return 'PurchasingAnalyticLoaderState(purchasing: $purchasing, failureOptionPurchasing: $failureOptionPurchasing, isFetching: $isFetching, dateFrom: $dateFrom, dateTo: $dateTo)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PurchasingAnalyticLoaderStateImpl && + (identical(other.purchasing, purchasing) || + other.purchasing == purchasing) && + (identical( + other.failureOptionPurchasing, + failureOptionPurchasing, + ) || + other.failureOptionPurchasing == failureOptionPurchasing) && + (identical(other.isFetching, isFetching) || + other.isFetching == isFetching) && + (identical(other.dateFrom, dateFrom) || + other.dateFrom == dateFrom) && + (identical(other.dateTo, dateTo) || other.dateTo == dateTo)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + purchasing, + failureOptionPurchasing, + isFetching, + dateFrom, + dateTo, + ); + + /// Create a copy of PurchasingAnalyticLoaderState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PurchasingAnalyticLoaderStateImplCopyWith< + _$PurchasingAnalyticLoaderStateImpl + > + get copyWith => + __$$PurchasingAnalyticLoaderStateImplCopyWithImpl< + _$PurchasingAnalyticLoaderStateImpl + >(this, _$identity); +} + +abstract class _PurchasingAnalyticLoaderState + implements PurchasingAnalyticLoaderState { + const factory _PurchasingAnalyticLoaderState({ + required final PurchasingAnalytic purchasing, + required final Option failureOptionPurchasing, + final bool isFetching, + required final DateTime dateFrom, + required final DateTime dateTo, + }) = _$PurchasingAnalyticLoaderStateImpl; + + @override + PurchasingAnalytic get purchasing; + @override + Option get failureOptionPurchasing; + @override + bool get isFetching; + @override + DateTime get dateFrom; + @override + DateTime get dateTo; + + /// Create a copy of PurchasingAnalyticLoaderState + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PurchasingAnalyticLoaderStateImplCopyWith< + _$PurchasingAnalyticLoaderStateImpl + > + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/application/analytic/purchasing_analytic_loader/purchasing_analytic_loader_event.dart b/lib/application/analytic/purchasing_analytic_loader/purchasing_analytic_loader_event.dart new file mode 100644 index 0000000..98419a2 --- /dev/null +++ b/lib/application/analytic/purchasing_analytic_loader/purchasing_analytic_loader_event.dart @@ -0,0 +1,11 @@ +part of 'purchasing_analytic_loader_bloc.dart'; + +@freezed +class PurchasingAnalyticLoaderEvent with _$PurchasingAnalyticLoaderEvent { + const factory PurchasingAnalyticLoaderEvent.rangeDateChanged( + DateTime dateFrom, + DateTime dateTo, + ) = _RangeDateChanged; + + const factory PurchasingAnalyticLoaderEvent.fetched() = _Fetched; +} diff --git a/lib/application/analytic/purchasing_analytic_loader/purchasing_analytic_loader_state.dart b/lib/application/analytic/purchasing_analytic_loader/purchasing_analytic_loader_state.dart new file mode 100644 index 0000000..b3ea6b7 --- /dev/null +++ b/lib/application/analytic/purchasing_analytic_loader/purchasing_analytic_loader_state.dart @@ -0,0 +1,20 @@ +part of 'purchasing_analytic_loader_bloc.dart'; + +@freezed +class PurchasingAnalyticLoaderState with _$PurchasingAnalyticLoaderState { + const factory PurchasingAnalyticLoaderState({ + required PurchasingAnalytic purchasing, + required Option failureOptionPurchasing, + @Default(false) bool isFetching, + required DateTime dateFrom, + required DateTime dateTo, + }) = _PurchasingAnalyticLoaderState; + + factory PurchasingAnalyticLoaderState.initial() => + PurchasingAnalyticLoaderState( + purchasing: PurchasingAnalytic.empty(), + failureOptionPurchasing: none(), + dateFrom: DateTime.now().subtract(const Duration(days: 30)), + dateTo: DateTime.now(), + ); +} diff --git a/lib/common/url/api_path.dart b/lib/common/url/api_path.dart index cdccbd3..f113574 100644 --- a/lib/common/url/api_path.dart +++ b/lib/common/url/api_path.dart @@ -11,6 +11,7 @@ class ApiPath { static const String productAnalytic = '/api/v1/analytics/products'; static const String paymentMethodAnalytic = '/api/v1/analytics/paymentMethods'; + static const String purchasingAnalytic = '/api/v1/analytics/purchasing'; // Inventory static const String inventoryReportDetail = diff --git a/lib/domain/analytic/analytic.dart b/lib/domain/analytic/analytic.dart index f51eb5a..4c09de3 100644 --- a/lib/domain/analytic/analytic.dart +++ b/lib/domain/analytic/analytic.dart @@ -11,4 +11,5 @@ part 'entities/inventory_analytic_entity.dart'; part 'entities/dashboard_analytic_entity.dart'; part 'entities/product_analytic_entity.dart'; part 'entities/payment_method_analytic_entity.dart'; +part 'entities/purchasing_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 5cd5ff1..def3f8b 100644 --- a/lib/domain/analytic/analytic.freezed.dart +++ b/lib/domain/analytic/analytic.freezed.dart @@ -7077,6 +7077,1459 @@ abstract class _PaymentMethodSummary implements PaymentMethodSummary { get copyWith => throw _privateConstructorUsedError; } +/// @nodoc +mixin _$PurchasingAnalytic { + String get organizationId => throw _privateConstructorUsedError; + String get outletId => throw _privateConstructorUsedError; + String get outletName => throw _privateConstructorUsedError; + DateTime get dateFrom => throw _privateConstructorUsedError; + DateTime get dateTo => throw _privateConstructorUsedError; + String get groupBy => throw _privateConstructorUsedError; + PurchasingAnalyticSummary get summary => throw _privateConstructorUsedError; + List get data => throw _privateConstructorUsedError; + List get ingredientData => + throw _privateConstructorUsedError; + List get vendorData => + throw _privateConstructorUsedError; + + /// Create a copy of PurchasingAnalytic + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PurchasingAnalyticCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PurchasingAnalyticCopyWith<$Res> { + factory $PurchasingAnalyticCopyWith( + PurchasingAnalytic value, + $Res Function(PurchasingAnalytic) then, + ) = _$PurchasingAnalyticCopyWithImpl<$Res, PurchasingAnalytic>; + @useResult + $Res call({ + String organizationId, + String outletId, + String outletName, + DateTime dateFrom, + DateTime dateTo, + String groupBy, + PurchasingAnalyticSummary summary, + List data, + List ingredientData, + List vendorData, + }); + + $PurchasingAnalyticSummaryCopyWith<$Res> get summary; +} + +/// @nodoc +class _$PurchasingAnalyticCopyWithImpl<$Res, $Val extends PurchasingAnalytic> + implements $PurchasingAnalyticCopyWith<$Res> { + _$PurchasingAnalyticCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PurchasingAnalytic + /// 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? outletName = null, + Object? dateFrom = null, + Object? dateTo = null, + Object? groupBy = null, + Object? summary = null, + Object? data = null, + Object? ingredientData = null, + Object? vendorData = 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, + outletName: null == outletName + ? _value.outletName + : outletName // 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 PurchasingAnalyticSummary, + data: null == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as List, + ingredientData: null == ingredientData + ? _value.ingredientData + : ingredientData // ignore: cast_nullable_to_non_nullable + as List, + vendorData: null == vendorData + ? _value.vendorData + : vendorData // ignore: cast_nullable_to_non_nullable + as List, + ) + as $Val, + ); + } + + /// Create a copy of PurchasingAnalytic + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $PurchasingAnalyticSummaryCopyWith<$Res> get summary { + return $PurchasingAnalyticSummaryCopyWith<$Res>(_value.summary, (value) { + return _then(_value.copyWith(summary: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$PurchasingAnalyticImplCopyWith<$Res> + implements $PurchasingAnalyticCopyWith<$Res> { + factory _$$PurchasingAnalyticImplCopyWith( + _$PurchasingAnalyticImpl value, + $Res Function(_$PurchasingAnalyticImpl) then, + ) = __$$PurchasingAnalyticImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String organizationId, + String outletId, + String outletName, + DateTime dateFrom, + DateTime dateTo, + String groupBy, + PurchasingAnalyticSummary summary, + List data, + List ingredientData, + List vendorData, + }); + + @override + $PurchasingAnalyticSummaryCopyWith<$Res> get summary; +} + +/// @nodoc +class __$$PurchasingAnalyticImplCopyWithImpl<$Res> + extends _$PurchasingAnalyticCopyWithImpl<$Res, _$PurchasingAnalyticImpl> + implements _$$PurchasingAnalyticImplCopyWith<$Res> { + __$$PurchasingAnalyticImplCopyWithImpl( + _$PurchasingAnalyticImpl _value, + $Res Function(_$PurchasingAnalyticImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PurchasingAnalytic + /// 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? outletName = null, + Object? dateFrom = null, + Object? dateTo = null, + Object? groupBy = null, + Object? summary = null, + Object? data = null, + Object? ingredientData = null, + Object? vendorData = null, + }) { + return _then( + _$PurchasingAnalyticImpl( + 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, + outletName: null == outletName + ? _value.outletName + : outletName // 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 PurchasingAnalyticSummary, + data: null == data + ? _value._data + : data // ignore: cast_nullable_to_non_nullable + as List, + ingredientData: null == ingredientData + ? _value._ingredientData + : ingredientData // ignore: cast_nullable_to_non_nullable + as List, + vendorData: null == vendorData + ? _value._vendorData + : vendorData // ignore: cast_nullable_to_non_nullable + as List, + ), + ); + } +} + +/// @nodoc + +class _$PurchasingAnalyticImpl implements _PurchasingAnalytic { + const _$PurchasingAnalyticImpl({ + required this.organizationId, + required this.outletId, + required this.outletName, + required this.dateFrom, + required this.dateTo, + required this.groupBy, + required this.summary, + required final List data, + required final List ingredientData, + required final List vendorData, + }) : _data = data, + _ingredientData = ingredientData, + _vendorData = vendorData; + + @override + final String organizationId; + @override + final String outletId; + @override + final String outletName; + @override + final DateTime dateFrom; + @override + final DateTime dateTo; + @override + final String groupBy; + @override + final PurchasingAnalyticSummary summary; + final List _data; + @override + List get data { + if (_data is EqualUnmodifiableListView) return _data; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_data); + } + + final List _ingredientData; + @override + List get ingredientData { + if (_ingredientData is EqualUnmodifiableListView) return _ingredientData; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_ingredientData); + } + + final List _vendorData; + @override + List get vendorData { + if (_vendorData is EqualUnmodifiableListView) return _vendorData; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_vendorData); + } + + @override + String toString() { + return 'PurchasingAnalytic(organizationId: $organizationId, outletId: $outletId, outletName: $outletName, dateFrom: $dateFrom, dateTo: $dateTo, groupBy: $groupBy, summary: $summary, data: $data, ingredientData: $ingredientData, vendorData: $vendorData)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PurchasingAnalyticImpl && + (identical(other.organizationId, organizationId) || + other.organizationId == organizationId) && + (identical(other.outletId, outletId) || + other.outletId == outletId) && + (identical(other.outletName, outletName) || + other.outletName == outletName) && + (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) && + const DeepCollectionEquality().equals( + other._ingredientData, + _ingredientData, + ) && + const DeepCollectionEquality().equals( + other._vendorData, + _vendorData, + )); + } + + @override + int get hashCode => Object.hash( + runtimeType, + organizationId, + outletId, + outletName, + dateFrom, + dateTo, + groupBy, + summary, + const DeepCollectionEquality().hash(_data), + const DeepCollectionEquality().hash(_ingredientData), + const DeepCollectionEquality().hash(_vendorData), + ); + + /// Create a copy of PurchasingAnalytic + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PurchasingAnalyticImplCopyWith<_$PurchasingAnalyticImpl> get copyWith => + __$$PurchasingAnalyticImplCopyWithImpl<_$PurchasingAnalyticImpl>( + this, + _$identity, + ); +} + +abstract class _PurchasingAnalytic implements PurchasingAnalytic { + const factory _PurchasingAnalytic({ + required final String organizationId, + required final String outletId, + required final String outletName, + required final DateTime dateFrom, + required final DateTime dateTo, + required final String groupBy, + required final PurchasingAnalyticSummary summary, + required final List data, + required final List ingredientData, + required final List vendorData, + }) = _$PurchasingAnalyticImpl; + + @override + String get organizationId; + @override + String get outletId; + @override + String get outletName; + @override + DateTime get dateFrom; + @override + DateTime get dateTo; + @override + String get groupBy; + @override + PurchasingAnalyticSummary get summary; + @override + List get data; + @override + List get ingredientData; + @override + List get vendorData; + + /// Create a copy of PurchasingAnalytic + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PurchasingAnalyticImplCopyWith<_$PurchasingAnalyticImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$PurchasingAnalyticSummary { + int get totalPurchases => throw _privateConstructorUsedError; + int get totalPurchaseOrders => throw _privateConstructorUsedError; + int get totalQuantity => throw _privateConstructorUsedError; + double get averagePurchaseOrderValue => throw _privateConstructorUsedError; + int get totalIngredients => throw _privateConstructorUsedError; + int get totalVendors => throw _privateConstructorUsedError; + + /// Create a copy of PurchasingAnalyticSummary + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PurchasingAnalyticSummaryCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PurchasingAnalyticSummaryCopyWith<$Res> { + factory $PurchasingAnalyticSummaryCopyWith( + PurchasingAnalyticSummary value, + $Res Function(PurchasingAnalyticSummary) then, + ) = _$PurchasingAnalyticSummaryCopyWithImpl<$Res, PurchasingAnalyticSummary>; + @useResult + $Res call({ + int totalPurchases, + int totalPurchaseOrders, + int totalQuantity, + double averagePurchaseOrderValue, + int totalIngredients, + int totalVendors, + }); +} + +/// @nodoc +class _$PurchasingAnalyticSummaryCopyWithImpl< + $Res, + $Val extends PurchasingAnalyticSummary +> + implements $PurchasingAnalyticSummaryCopyWith<$Res> { + _$PurchasingAnalyticSummaryCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PurchasingAnalyticSummary + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? totalPurchases = null, + Object? totalPurchaseOrders = null, + Object? totalQuantity = null, + Object? averagePurchaseOrderValue = null, + Object? totalIngredients = null, + Object? totalVendors = null, + }) { + return _then( + _value.copyWith( + totalPurchases: null == totalPurchases + ? _value.totalPurchases + : totalPurchases // ignore: cast_nullable_to_non_nullable + as int, + totalPurchaseOrders: null == totalPurchaseOrders + ? _value.totalPurchaseOrders + : totalPurchaseOrders // ignore: cast_nullable_to_non_nullable + as int, + totalQuantity: null == totalQuantity + ? _value.totalQuantity + : totalQuantity // ignore: cast_nullable_to_non_nullable + as int, + averagePurchaseOrderValue: null == averagePurchaseOrderValue + ? _value.averagePurchaseOrderValue + : averagePurchaseOrderValue // ignore: cast_nullable_to_non_nullable + as double, + totalIngredients: null == totalIngredients + ? _value.totalIngredients + : totalIngredients // ignore: cast_nullable_to_non_nullable + as int, + totalVendors: null == totalVendors + ? _value.totalVendors + : totalVendors // ignore: cast_nullable_to_non_nullable + as int, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PurchasingAnalyticSummaryImplCopyWith<$Res> + implements $PurchasingAnalyticSummaryCopyWith<$Res> { + factory _$$PurchasingAnalyticSummaryImplCopyWith( + _$PurchasingAnalyticSummaryImpl value, + $Res Function(_$PurchasingAnalyticSummaryImpl) then, + ) = __$$PurchasingAnalyticSummaryImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + int totalPurchases, + int totalPurchaseOrders, + int totalQuantity, + double averagePurchaseOrderValue, + int totalIngredients, + int totalVendors, + }); +} + +/// @nodoc +class __$$PurchasingAnalyticSummaryImplCopyWithImpl<$Res> + extends + _$PurchasingAnalyticSummaryCopyWithImpl< + $Res, + _$PurchasingAnalyticSummaryImpl + > + implements _$$PurchasingAnalyticSummaryImplCopyWith<$Res> { + __$$PurchasingAnalyticSummaryImplCopyWithImpl( + _$PurchasingAnalyticSummaryImpl _value, + $Res Function(_$PurchasingAnalyticSummaryImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PurchasingAnalyticSummary + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? totalPurchases = null, + Object? totalPurchaseOrders = null, + Object? totalQuantity = null, + Object? averagePurchaseOrderValue = null, + Object? totalIngredients = null, + Object? totalVendors = null, + }) { + return _then( + _$PurchasingAnalyticSummaryImpl( + totalPurchases: null == totalPurchases + ? _value.totalPurchases + : totalPurchases // ignore: cast_nullable_to_non_nullable + as int, + totalPurchaseOrders: null == totalPurchaseOrders + ? _value.totalPurchaseOrders + : totalPurchaseOrders // ignore: cast_nullable_to_non_nullable + as int, + totalQuantity: null == totalQuantity + ? _value.totalQuantity + : totalQuantity // ignore: cast_nullable_to_non_nullable + as int, + averagePurchaseOrderValue: null == averagePurchaseOrderValue + ? _value.averagePurchaseOrderValue + : averagePurchaseOrderValue // ignore: cast_nullable_to_non_nullable + as double, + totalIngredients: null == totalIngredients + ? _value.totalIngredients + : totalIngredients // ignore: cast_nullable_to_non_nullable + as int, + totalVendors: null == totalVendors + ? _value.totalVendors + : totalVendors // ignore: cast_nullable_to_non_nullable + as int, + ), + ); + } +} + +/// @nodoc + +class _$PurchasingAnalyticSummaryImpl implements _PurchasingAnalyticSummary { + const _$PurchasingAnalyticSummaryImpl({ + required this.totalPurchases, + required this.totalPurchaseOrders, + required this.totalQuantity, + required this.averagePurchaseOrderValue, + required this.totalIngredients, + required this.totalVendors, + }); + + @override + final int totalPurchases; + @override + final int totalPurchaseOrders; + @override + final int totalQuantity; + @override + final double averagePurchaseOrderValue; + @override + final int totalIngredients; + @override + final int totalVendors; + + @override + String toString() { + return 'PurchasingAnalyticSummary(totalPurchases: $totalPurchases, totalPurchaseOrders: $totalPurchaseOrders, totalQuantity: $totalQuantity, averagePurchaseOrderValue: $averagePurchaseOrderValue, totalIngredients: $totalIngredients, totalVendors: $totalVendors)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PurchasingAnalyticSummaryImpl && + (identical(other.totalPurchases, totalPurchases) || + other.totalPurchases == totalPurchases) && + (identical(other.totalPurchaseOrders, totalPurchaseOrders) || + other.totalPurchaseOrders == totalPurchaseOrders) && + (identical(other.totalQuantity, totalQuantity) || + other.totalQuantity == totalQuantity) && + (identical( + other.averagePurchaseOrderValue, + averagePurchaseOrderValue, + ) || + other.averagePurchaseOrderValue == averagePurchaseOrderValue) && + (identical(other.totalIngredients, totalIngredients) || + other.totalIngredients == totalIngredients) && + (identical(other.totalVendors, totalVendors) || + other.totalVendors == totalVendors)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + totalPurchases, + totalPurchaseOrders, + totalQuantity, + averagePurchaseOrderValue, + totalIngredients, + totalVendors, + ); + + /// Create a copy of PurchasingAnalyticSummary + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PurchasingAnalyticSummaryImplCopyWith<_$PurchasingAnalyticSummaryImpl> + get copyWith => + __$$PurchasingAnalyticSummaryImplCopyWithImpl< + _$PurchasingAnalyticSummaryImpl + >(this, _$identity); +} + +abstract class _PurchasingAnalyticSummary implements PurchasingAnalyticSummary { + const factory _PurchasingAnalyticSummary({ + required final int totalPurchases, + required final int totalPurchaseOrders, + required final int totalQuantity, + required final double averagePurchaseOrderValue, + required final int totalIngredients, + required final int totalVendors, + }) = _$PurchasingAnalyticSummaryImpl; + + @override + int get totalPurchases; + @override + int get totalPurchaseOrders; + @override + int get totalQuantity; + @override + double get averagePurchaseOrderValue; + @override + int get totalIngredients; + @override + int get totalVendors; + + /// Create a copy of PurchasingAnalyticSummary + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PurchasingAnalyticSummaryImplCopyWith<_$PurchasingAnalyticSummaryImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$PurchasingAnalyticData { + DateTime get date => throw _privateConstructorUsedError; + int get purchases => throw _privateConstructorUsedError; + int get purchaseOrders => throw _privateConstructorUsedError; + int get quantity => throw _privateConstructorUsedError; + int get ingredients => throw _privateConstructorUsedError; + int get vendors => throw _privateConstructorUsedError; + + /// Create a copy of PurchasingAnalyticData + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PurchasingAnalyticDataCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PurchasingAnalyticDataCopyWith<$Res> { + factory $PurchasingAnalyticDataCopyWith( + PurchasingAnalyticData value, + $Res Function(PurchasingAnalyticData) then, + ) = _$PurchasingAnalyticDataCopyWithImpl<$Res, PurchasingAnalyticData>; + @useResult + $Res call({ + DateTime date, + int purchases, + int purchaseOrders, + int quantity, + int ingredients, + int vendors, + }); +} + +/// @nodoc +class _$PurchasingAnalyticDataCopyWithImpl< + $Res, + $Val extends PurchasingAnalyticData +> + implements $PurchasingAnalyticDataCopyWith<$Res> { + _$PurchasingAnalyticDataCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PurchasingAnalyticData + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? date = null, + Object? purchases = null, + Object? purchaseOrders = null, + Object? quantity = null, + Object? ingredients = null, + Object? vendors = null, + }) { + return _then( + _value.copyWith( + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as DateTime, + purchases: null == purchases + ? _value.purchases + : purchases // ignore: cast_nullable_to_non_nullable + as int, + purchaseOrders: null == purchaseOrders + ? _value.purchaseOrders + : purchaseOrders // ignore: cast_nullable_to_non_nullable + as int, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + ingredients: null == ingredients + ? _value.ingredients + : ingredients // ignore: cast_nullable_to_non_nullable + as int, + vendors: null == vendors + ? _value.vendors + : vendors // ignore: cast_nullable_to_non_nullable + as int, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PurchasingAnalyticDataImplCopyWith<$Res> + implements $PurchasingAnalyticDataCopyWith<$Res> { + factory _$$PurchasingAnalyticDataImplCopyWith( + _$PurchasingAnalyticDataImpl value, + $Res Function(_$PurchasingAnalyticDataImpl) then, + ) = __$$PurchasingAnalyticDataImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + DateTime date, + int purchases, + int purchaseOrders, + int quantity, + int ingredients, + int vendors, + }); +} + +/// @nodoc +class __$$PurchasingAnalyticDataImplCopyWithImpl<$Res> + extends + _$PurchasingAnalyticDataCopyWithImpl<$Res, _$PurchasingAnalyticDataImpl> + implements _$$PurchasingAnalyticDataImplCopyWith<$Res> { + __$$PurchasingAnalyticDataImplCopyWithImpl( + _$PurchasingAnalyticDataImpl _value, + $Res Function(_$PurchasingAnalyticDataImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PurchasingAnalyticData + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? date = null, + Object? purchases = null, + Object? purchaseOrders = null, + Object? quantity = null, + Object? ingredients = null, + Object? vendors = null, + }) { + return _then( + _$PurchasingAnalyticDataImpl( + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as DateTime, + purchases: null == purchases + ? _value.purchases + : purchases // ignore: cast_nullable_to_non_nullable + as int, + purchaseOrders: null == purchaseOrders + ? _value.purchaseOrders + : purchaseOrders // ignore: cast_nullable_to_non_nullable + as int, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + ingredients: null == ingredients + ? _value.ingredients + : ingredients // ignore: cast_nullable_to_non_nullable + as int, + vendors: null == vendors + ? _value.vendors + : vendors // ignore: cast_nullable_to_non_nullable + as int, + ), + ); + } +} + +/// @nodoc + +class _$PurchasingAnalyticDataImpl implements _PurchasingAnalyticData { + const _$PurchasingAnalyticDataImpl({ + required this.date, + required this.purchases, + required this.purchaseOrders, + required this.quantity, + required this.ingredients, + required this.vendors, + }); + + @override + final DateTime date; + @override + final int purchases; + @override + final int purchaseOrders; + @override + final int quantity; + @override + final int ingredients; + @override + final int vendors; + + @override + String toString() { + return 'PurchasingAnalyticData(date: $date, purchases: $purchases, purchaseOrders: $purchaseOrders, quantity: $quantity, ingredients: $ingredients, vendors: $vendors)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PurchasingAnalyticDataImpl && + (identical(other.date, date) || other.date == date) && + (identical(other.purchases, purchases) || + other.purchases == purchases) && + (identical(other.purchaseOrders, purchaseOrders) || + other.purchaseOrders == purchaseOrders) && + (identical(other.quantity, quantity) || + other.quantity == quantity) && + (identical(other.ingredients, ingredients) || + other.ingredients == ingredients) && + (identical(other.vendors, vendors) || other.vendors == vendors)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + date, + purchases, + purchaseOrders, + quantity, + ingredients, + vendors, + ); + + /// Create a copy of PurchasingAnalyticData + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PurchasingAnalyticDataImplCopyWith<_$PurchasingAnalyticDataImpl> + get copyWith => + __$$PurchasingAnalyticDataImplCopyWithImpl<_$PurchasingAnalyticDataImpl>( + this, + _$identity, + ); +} + +abstract class _PurchasingAnalyticData implements PurchasingAnalyticData { + const factory _PurchasingAnalyticData({ + required final DateTime date, + required final int purchases, + required final int purchaseOrders, + required final int quantity, + required final int ingredients, + required final int vendors, + }) = _$PurchasingAnalyticDataImpl; + + @override + DateTime get date; + @override + int get purchases; + @override + int get purchaseOrders; + @override + int get quantity; + @override + int get ingredients; + @override + int get vendors; + + /// Create a copy of PurchasingAnalyticData + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PurchasingAnalyticDataImplCopyWith<_$PurchasingAnalyticDataImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$PurchasingIngredientData { + String get ingredientId => throw _privateConstructorUsedError; + String get ingredientName => throw _privateConstructorUsedError; + int get quantity => throw _privateConstructorUsedError; + int get totalCost => throw _privateConstructorUsedError; + double get averageUnitCost => throw _privateConstructorUsedError; + int get purchaseOrderCount => throw _privateConstructorUsedError; + + /// Create a copy of PurchasingIngredientData + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PurchasingIngredientDataCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PurchasingIngredientDataCopyWith<$Res> { + factory $PurchasingIngredientDataCopyWith( + PurchasingIngredientData value, + $Res Function(PurchasingIngredientData) then, + ) = _$PurchasingIngredientDataCopyWithImpl<$Res, PurchasingIngredientData>; + @useResult + $Res call({ + String ingredientId, + String ingredientName, + int quantity, + int totalCost, + double averageUnitCost, + int purchaseOrderCount, + }); +} + +/// @nodoc +class _$PurchasingIngredientDataCopyWithImpl< + $Res, + $Val extends PurchasingIngredientData +> + implements $PurchasingIngredientDataCopyWith<$Res> { + _$PurchasingIngredientDataCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PurchasingIngredientData + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? ingredientId = null, + Object? ingredientName = null, + Object? quantity = null, + Object? totalCost = null, + Object? averageUnitCost = null, + Object? purchaseOrderCount = null, + }) { + return _then( + _value.copyWith( + ingredientId: null == ingredientId + ? _value.ingredientId + : ingredientId // ignore: cast_nullable_to_non_nullable + as String, + ingredientName: null == ingredientName + ? _value.ingredientName + : ingredientName // ignore: cast_nullable_to_non_nullable + as String, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + totalCost: null == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as int, + averageUnitCost: null == averageUnitCost + ? _value.averageUnitCost + : averageUnitCost // ignore: cast_nullable_to_non_nullable + as double, + purchaseOrderCount: null == purchaseOrderCount + ? _value.purchaseOrderCount + : purchaseOrderCount // ignore: cast_nullable_to_non_nullable + as int, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PurchasingIngredientDataImplCopyWith<$Res> + implements $PurchasingIngredientDataCopyWith<$Res> { + factory _$$PurchasingIngredientDataImplCopyWith( + _$PurchasingIngredientDataImpl value, + $Res Function(_$PurchasingIngredientDataImpl) then, + ) = __$$PurchasingIngredientDataImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String ingredientId, + String ingredientName, + int quantity, + int totalCost, + double averageUnitCost, + int purchaseOrderCount, + }); +} + +/// @nodoc +class __$$PurchasingIngredientDataImplCopyWithImpl<$Res> + extends + _$PurchasingIngredientDataCopyWithImpl< + $Res, + _$PurchasingIngredientDataImpl + > + implements _$$PurchasingIngredientDataImplCopyWith<$Res> { + __$$PurchasingIngredientDataImplCopyWithImpl( + _$PurchasingIngredientDataImpl _value, + $Res Function(_$PurchasingIngredientDataImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PurchasingIngredientData + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? ingredientId = null, + Object? ingredientName = null, + Object? quantity = null, + Object? totalCost = null, + Object? averageUnitCost = null, + Object? purchaseOrderCount = null, + }) { + return _then( + _$PurchasingIngredientDataImpl( + ingredientId: null == ingredientId + ? _value.ingredientId + : ingredientId // ignore: cast_nullable_to_non_nullable + as String, + ingredientName: null == ingredientName + ? _value.ingredientName + : ingredientName // ignore: cast_nullable_to_non_nullable + as String, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + totalCost: null == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as int, + averageUnitCost: null == averageUnitCost + ? _value.averageUnitCost + : averageUnitCost // ignore: cast_nullable_to_non_nullable + as double, + purchaseOrderCount: null == purchaseOrderCount + ? _value.purchaseOrderCount + : purchaseOrderCount // ignore: cast_nullable_to_non_nullable + as int, + ), + ); + } +} + +/// @nodoc + +class _$PurchasingIngredientDataImpl implements _PurchasingIngredientData { + const _$PurchasingIngredientDataImpl({ + required this.ingredientId, + required this.ingredientName, + required this.quantity, + required this.totalCost, + required this.averageUnitCost, + required this.purchaseOrderCount, + }); + + @override + final String ingredientId; + @override + final String ingredientName; + @override + final int quantity; + @override + final int totalCost; + @override + final double averageUnitCost; + @override + final int purchaseOrderCount; + + @override + String toString() { + return 'PurchasingIngredientData(ingredientId: $ingredientId, ingredientName: $ingredientName, quantity: $quantity, totalCost: $totalCost, averageUnitCost: $averageUnitCost, purchaseOrderCount: $purchaseOrderCount)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PurchasingIngredientDataImpl && + (identical(other.ingredientId, ingredientId) || + other.ingredientId == ingredientId) && + (identical(other.ingredientName, ingredientName) || + other.ingredientName == ingredientName) && + (identical(other.quantity, quantity) || + other.quantity == quantity) && + (identical(other.totalCost, totalCost) || + other.totalCost == totalCost) && + (identical(other.averageUnitCost, averageUnitCost) || + other.averageUnitCost == averageUnitCost) && + (identical(other.purchaseOrderCount, purchaseOrderCount) || + other.purchaseOrderCount == purchaseOrderCount)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + ingredientId, + ingredientName, + quantity, + totalCost, + averageUnitCost, + purchaseOrderCount, + ); + + /// Create a copy of PurchasingIngredientData + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PurchasingIngredientDataImplCopyWith<_$PurchasingIngredientDataImpl> + get copyWith => + __$$PurchasingIngredientDataImplCopyWithImpl< + _$PurchasingIngredientDataImpl + >(this, _$identity); +} + +abstract class _PurchasingIngredientData implements PurchasingIngredientData { + const factory _PurchasingIngredientData({ + required final String ingredientId, + required final String ingredientName, + required final int quantity, + required final int totalCost, + required final double averageUnitCost, + required final int purchaseOrderCount, + }) = _$PurchasingIngredientDataImpl; + + @override + String get ingredientId; + @override + String get ingredientName; + @override + int get quantity; + @override + int get totalCost; + @override + double get averageUnitCost; + @override + int get purchaseOrderCount; + + /// Create a copy of PurchasingIngredientData + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PurchasingIngredientDataImplCopyWith<_$PurchasingIngredientDataImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$PurchasingVendorData { + String get vendorId => throw _privateConstructorUsedError; + String get vendorName => throw _privateConstructorUsedError; + int get totalCost => throw _privateConstructorUsedError; + int get purchaseOrderCount => throw _privateConstructorUsedError; + int get ingredientCount => throw _privateConstructorUsedError; + int get quantity => throw _privateConstructorUsedError; + + /// Create a copy of PurchasingVendorData + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PurchasingVendorDataCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PurchasingVendorDataCopyWith<$Res> { + factory $PurchasingVendorDataCopyWith( + PurchasingVendorData value, + $Res Function(PurchasingVendorData) then, + ) = _$PurchasingVendorDataCopyWithImpl<$Res, PurchasingVendorData>; + @useResult + $Res call({ + String vendorId, + String vendorName, + int totalCost, + int purchaseOrderCount, + int ingredientCount, + int quantity, + }); +} + +/// @nodoc +class _$PurchasingVendorDataCopyWithImpl< + $Res, + $Val extends PurchasingVendorData +> + implements $PurchasingVendorDataCopyWith<$Res> { + _$PurchasingVendorDataCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PurchasingVendorData + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? vendorId = null, + Object? vendorName = null, + Object? totalCost = null, + Object? purchaseOrderCount = null, + Object? ingredientCount = null, + Object? quantity = null, + }) { + return _then( + _value.copyWith( + vendorId: null == vendorId + ? _value.vendorId + : vendorId // ignore: cast_nullable_to_non_nullable + as String, + vendorName: null == vendorName + ? _value.vendorName + : vendorName // ignore: cast_nullable_to_non_nullable + as String, + totalCost: null == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as int, + purchaseOrderCount: null == purchaseOrderCount + ? _value.purchaseOrderCount + : purchaseOrderCount // ignore: cast_nullable_to_non_nullable + as int, + ingredientCount: null == ingredientCount + ? _value.ingredientCount + : ingredientCount // ignore: cast_nullable_to_non_nullable + as int, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PurchasingVendorDataImplCopyWith<$Res> + implements $PurchasingVendorDataCopyWith<$Res> { + factory _$$PurchasingVendorDataImplCopyWith( + _$PurchasingVendorDataImpl value, + $Res Function(_$PurchasingVendorDataImpl) then, + ) = __$$PurchasingVendorDataImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String vendorId, + String vendorName, + int totalCost, + int purchaseOrderCount, + int ingredientCount, + int quantity, + }); +} + +/// @nodoc +class __$$PurchasingVendorDataImplCopyWithImpl<$Res> + extends _$PurchasingVendorDataCopyWithImpl<$Res, _$PurchasingVendorDataImpl> + implements _$$PurchasingVendorDataImplCopyWith<$Res> { + __$$PurchasingVendorDataImplCopyWithImpl( + _$PurchasingVendorDataImpl _value, + $Res Function(_$PurchasingVendorDataImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PurchasingVendorData + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? vendorId = null, + Object? vendorName = null, + Object? totalCost = null, + Object? purchaseOrderCount = null, + Object? ingredientCount = null, + Object? quantity = null, + }) { + return _then( + _$PurchasingVendorDataImpl( + vendorId: null == vendorId + ? _value.vendorId + : vendorId // ignore: cast_nullable_to_non_nullable + as String, + vendorName: null == vendorName + ? _value.vendorName + : vendorName // ignore: cast_nullable_to_non_nullable + as String, + totalCost: null == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as int, + purchaseOrderCount: null == purchaseOrderCount + ? _value.purchaseOrderCount + : purchaseOrderCount // ignore: cast_nullable_to_non_nullable + as int, + ingredientCount: null == ingredientCount + ? _value.ingredientCount + : ingredientCount // ignore: cast_nullable_to_non_nullable + as int, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + ), + ); + } +} + +/// @nodoc + +class _$PurchasingVendorDataImpl implements _PurchasingVendorData { + const _$PurchasingVendorDataImpl({ + required this.vendorId, + required this.vendorName, + required this.totalCost, + required this.purchaseOrderCount, + required this.ingredientCount, + required this.quantity, + }); + + @override + final String vendorId; + @override + final String vendorName; + @override + final int totalCost; + @override + final int purchaseOrderCount; + @override + final int ingredientCount; + @override + final int quantity; + + @override + String toString() { + return 'PurchasingVendorData(vendorId: $vendorId, vendorName: $vendorName, totalCost: $totalCost, purchaseOrderCount: $purchaseOrderCount, ingredientCount: $ingredientCount, quantity: $quantity)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PurchasingVendorDataImpl && + (identical(other.vendorId, vendorId) || + other.vendorId == vendorId) && + (identical(other.vendorName, vendorName) || + other.vendorName == vendorName) && + (identical(other.totalCost, totalCost) || + other.totalCost == totalCost) && + (identical(other.purchaseOrderCount, purchaseOrderCount) || + other.purchaseOrderCount == purchaseOrderCount) && + (identical(other.ingredientCount, ingredientCount) || + other.ingredientCount == ingredientCount) && + (identical(other.quantity, quantity) || + other.quantity == quantity)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + vendorId, + vendorName, + totalCost, + purchaseOrderCount, + ingredientCount, + quantity, + ); + + /// Create a copy of PurchasingVendorData + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PurchasingVendorDataImplCopyWith<_$PurchasingVendorDataImpl> + get copyWith => + __$$PurchasingVendorDataImplCopyWithImpl<_$PurchasingVendorDataImpl>( + this, + _$identity, + ); +} + +abstract class _PurchasingVendorData implements PurchasingVendorData { + const factory _PurchasingVendorData({ + required final String vendorId, + required final String vendorName, + required final int totalCost, + required final int purchaseOrderCount, + required final int ingredientCount, + required final int quantity, + }) = _$PurchasingVendorDataImpl; + + @override + String get vendorId; + @override + String get vendorName; + @override + int get totalCost; + @override + int get purchaseOrderCount; + @override + int get ingredientCount; + @override + int get quantity; + + /// Create a copy of PurchasingVendorData + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PurchasingVendorDataImplCopyWith<_$PurchasingVendorDataImpl> + get copyWith => throw _privateConstructorUsedError; +} + /// @nodoc mixin _$AnalyticFailure { @optionalTypeArgs diff --git a/lib/domain/analytic/entities/purchasing_analytic_entity.dart b/lib/domain/analytic/entities/purchasing_analytic_entity.dart new file mode 100644 index 0000000..4488c65 --- /dev/null +++ b/lib/domain/analytic/entities/purchasing_analytic_entity.dart @@ -0,0 +1,116 @@ +part of '../analytic.dart'; + +@freezed +class PurchasingAnalytic with _$PurchasingAnalytic { + const factory PurchasingAnalytic({ + required String organizationId, + required String outletId, + required String outletName, + required DateTime dateFrom, + required DateTime dateTo, + required String groupBy, + required PurchasingAnalyticSummary summary, + required List data, + required List ingredientData, + required List vendorData, + }) = _PurchasingAnalytic; + + factory PurchasingAnalytic.empty() => PurchasingAnalytic( + organizationId: '', + outletId: '', + outletName: '', + dateFrom: DateTime.fromMillisecondsSinceEpoch(0), + dateTo: DateTime.fromMillisecondsSinceEpoch(0), + groupBy: '', + summary: PurchasingAnalyticSummary.empty(), + data: [], + ingredientData: [], + vendorData: [], + ); +} + +@freezed +class PurchasingAnalyticSummary with _$PurchasingAnalyticSummary { + const factory PurchasingAnalyticSummary({ + required int totalPurchases, + required int totalPurchaseOrders, + required int totalQuantity, + required double averagePurchaseOrderValue, + required int totalIngredients, + required int totalVendors, + }) = _PurchasingAnalyticSummary; + + factory PurchasingAnalyticSummary.empty() => + const PurchasingAnalyticSummary( + totalPurchases: 0, + totalPurchaseOrders: 0, + totalQuantity: 0, + averagePurchaseOrderValue: 0, + totalIngredients: 0, + totalVendors: 0, + ); +} + +@freezed +class PurchasingAnalyticData with _$PurchasingAnalyticData { + const factory PurchasingAnalyticData({ + required DateTime date, + required int purchases, + required int purchaseOrders, + required int quantity, + required int ingredients, + required int vendors, + }) = _PurchasingAnalyticData; + + factory PurchasingAnalyticData.empty() => PurchasingAnalyticData( + date: DateTime.fromMillisecondsSinceEpoch(0), + purchases: 0, + purchaseOrders: 0, + quantity: 0, + ingredients: 0, + vendors: 0, + ); +} + +@freezed +class PurchasingIngredientData with _$PurchasingIngredientData { + const factory PurchasingIngredientData({ + required String ingredientId, + required String ingredientName, + required int quantity, + required int totalCost, + required double averageUnitCost, + required int purchaseOrderCount, + }) = _PurchasingIngredientData; + + factory PurchasingIngredientData.empty() => + const PurchasingIngredientData( + ingredientId: '', + ingredientName: '', + quantity: 0, + totalCost: 0, + averageUnitCost: 0, + purchaseOrderCount: 0, + ); +} + +@freezed +class PurchasingVendorData with _$PurchasingVendorData { + const factory PurchasingVendorData({ + required String vendorId, + required String vendorName, + required int totalCost, + required int purchaseOrderCount, + required int ingredientCount, + required int quantity, + }) = _PurchasingVendorData; + + factory PurchasingVendorData.empty() => const PurchasingVendorData( + vendorId: '', + vendorName: '', + totalCost: 0, + purchaseOrderCount: 0, + ingredientCount: 0, + quantity: 0, + ); +} diff --git a/lib/domain/analytic/repositories/i_analytic_repository.dart b/lib/domain/analytic/repositories/i_analytic_repository.dart index dbaf131..b8b8d4e 100644 --- a/lib/domain/analytic/repositories/i_analytic_repository.dart +++ b/lib/domain/analytic/repositories/i_analytic_repository.dart @@ -44,4 +44,10 @@ abstract class IAnalyticRepository { required DateTime dateTo, String? outletId, }); + + Future> getPurchasing({ + required DateTime dateFrom, + required DateTime dateTo, + String? outletId, + }); } diff --git a/lib/infrastructure/analytic/analytic_dtos.dart b/lib/infrastructure/analytic/analytic_dtos.dart index abdb439..bdf49d5 100644 --- a/lib/infrastructure/analytic/analytic_dtos.dart +++ b/lib/infrastructure/analytic/analytic_dtos.dart @@ -12,3 +12,4 @@ part 'dto/inventory_analytic_dto.dart'; part 'dto/dashboard_analytic_dto.dart'; part 'dto/product_analytic_dto.dart'; part 'dto/payment_method_analytic_dto.dart'; +part 'dto/purchasing_analytic_dto.dart'; diff --git a/lib/infrastructure/analytic/analytic_dtos.freezed.dart b/lib/infrastructure/analytic/analytic_dtos.freezed.dart index f5f56fd..93db295 100644 --- a/lib/infrastructure/analytic/analytic_dtos.freezed.dart +++ b/lib/infrastructure/analytic/analytic_dtos.freezed.dart @@ -8230,3 +8230,1719 @@ abstract class _PaymentMethodSummaryDto extends PaymentMethodSummaryDto { _$$PaymentMethodSummaryDtoImplCopyWith<_$PaymentMethodSummaryDtoImpl> get copyWith => throw _privateConstructorUsedError; } + +PurchasingAnalyticDto _$PurchasingAnalyticDtoFromJson( + Map json, +) { + return _PurchasingAnalyticDto.fromJson(json); +} + +/// @nodoc +mixin _$PurchasingAnalyticDto { + @JsonKey(name: 'organization_id') + String? get organizationId => throw _privateConstructorUsedError; + @JsonKey(name: 'outlet_id') + String? get outletId => throw _privateConstructorUsedError; + @JsonKey(name: 'outlet_name') + String? get outletName => 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') + PurchasingAnalyticSummaryDto? get summary => + throw _privateConstructorUsedError; + @JsonKey(name: 'data') + List? get data => + throw _privateConstructorUsedError; + @JsonKey(name: 'ingredient_data') + List? get ingredientData => + throw _privateConstructorUsedError; + @JsonKey(name: 'vendor_data') + List? get vendorData => + throw _privateConstructorUsedError; + + /// Serializes this PurchasingAnalyticDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PurchasingAnalyticDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PurchasingAnalyticDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PurchasingAnalyticDtoCopyWith<$Res> { + factory $PurchasingAnalyticDtoCopyWith( + PurchasingAnalyticDto value, + $Res Function(PurchasingAnalyticDto) then, + ) = _$PurchasingAnalyticDtoCopyWithImpl<$Res, PurchasingAnalyticDto>; + @useResult + $Res call({ + @JsonKey(name: 'organization_id') String? organizationId, + @JsonKey(name: 'outlet_id') String? outletId, + @JsonKey(name: 'outlet_name') String? outletName, + @JsonKey(name: 'date_from') DateTime? dateFrom, + @JsonKey(name: 'date_to') DateTime? dateTo, + @JsonKey(name: 'group_by') String? groupBy, + @JsonKey(name: 'summary') PurchasingAnalyticSummaryDto? summary, + @JsonKey(name: 'data') List? data, + @JsonKey(name: 'ingredient_data') + List? ingredientData, + @JsonKey(name: 'vendor_data') List? vendorData, + }); + + $PurchasingAnalyticSummaryDtoCopyWith<$Res>? get summary; +} + +/// @nodoc +class _$PurchasingAnalyticDtoCopyWithImpl< + $Res, + $Val extends PurchasingAnalyticDto +> + implements $PurchasingAnalyticDtoCopyWith<$Res> { + _$PurchasingAnalyticDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PurchasingAnalyticDto + /// 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? outletName = freezed, + Object? dateFrom = freezed, + Object? dateTo = freezed, + Object? groupBy = freezed, + Object? summary = freezed, + Object? data = freezed, + Object? ingredientData = freezed, + Object? vendorData = 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?, + outletName: freezed == outletName + ? _value.outletName + : outletName // 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 PurchasingAnalyticSummaryDto?, + data: freezed == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as List?, + ingredientData: freezed == ingredientData + ? _value.ingredientData + : ingredientData // ignore: cast_nullable_to_non_nullable + as List?, + vendorData: freezed == vendorData + ? _value.vendorData + : vendorData // ignore: cast_nullable_to_non_nullable + as List?, + ) + as $Val, + ); + } + + /// Create a copy of PurchasingAnalyticDto + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $PurchasingAnalyticSummaryDtoCopyWith<$Res>? get summary { + if (_value.summary == null) { + return null; + } + + return $PurchasingAnalyticSummaryDtoCopyWith<$Res>(_value.summary!, ( + value, + ) { + return _then(_value.copyWith(summary: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$PurchasingAnalyticDtoImplCopyWith<$Res> + implements $PurchasingAnalyticDtoCopyWith<$Res> { + factory _$$PurchasingAnalyticDtoImplCopyWith( + _$PurchasingAnalyticDtoImpl value, + $Res Function(_$PurchasingAnalyticDtoImpl) then, + ) = __$$PurchasingAnalyticDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: 'organization_id') String? organizationId, + @JsonKey(name: 'outlet_id') String? outletId, + @JsonKey(name: 'outlet_name') String? outletName, + @JsonKey(name: 'date_from') DateTime? dateFrom, + @JsonKey(name: 'date_to') DateTime? dateTo, + @JsonKey(name: 'group_by') String? groupBy, + @JsonKey(name: 'summary') PurchasingAnalyticSummaryDto? summary, + @JsonKey(name: 'data') List? data, + @JsonKey(name: 'ingredient_data') + List? ingredientData, + @JsonKey(name: 'vendor_data') List? vendorData, + }); + + @override + $PurchasingAnalyticSummaryDtoCopyWith<$Res>? get summary; +} + +/// @nodoc +class __$$PurchasingAnalyticDtoImplCopyWithImpl<$Res> + extends + _$PurchasingAnalyticDtoCopyWithImpl<$Res, _$PurchasingAnalyticDtoImpl> + implements _$$PurchasingAnalyticDtoImplCopyWith<$Res> { + __$$PurchasingAnalyticDtoImplCopyWithImpl( + _$PurchasingAnalyticDtoImpl _value, + $Res Function(_$PurchasingAnalyticDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PurchasingAnalyticDto + /// 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? outletName = freezed, + Object? dateFrom = freezed, + Object? dateTo = freezed, + Object? groupBy = freezed, + Object? summary = freezed, + Object? data = freezed, + Object? ingredientData = freezed, + Object? vendorData = freezed, + }) { + return _then( + _$PurchasingAnalyticDtoImpl( + 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?, + outletName: freezed == outletName + ? _value.outletName + : outletName // 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 PurchasingAnalyticSummaryDto?, + data: freezed == data + ? _value._data + : data // ignore: cast_nullable_to_non_nullable + as List?, + ingredientData: freezed == ingredientData + ? _value._ingredientData + : ingredientData // ignore: cast_nullable_to_non_nullable + as List?, + vendorData: freezed == vendorData + ? _value._vendorData + : vendorData // ignore: cast_nullable_to_non_nullable + as List?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$PurchasingAnalyticDtoImpl extends _PurchasingAnalyticDto { + const _$PurchasingAnalyticDtoImpl({ + @JsonKey(name: 'organization_id') this.organizationId, + @JsonKey(name: 'outlet_id') this.outletId, + @JsonKey(name: 'outlet_name') this.outletName, + @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, + @JsonKey(name: 'ingredient_data') + final List? ingredientData, + @JsonKey(name: 'vendor_data') + final List? vendorData, + }) : _data = data, + _ingredientData = ingredientData, + _vendorData = vendorData, + super._(); + + factory _$PurchasingAnalyticDtoImpl.fromJson(Map json) => + _$$PurchasingAnalyticDtoImplFromJson(json); + + @override + @JsonKey(name: 'organization_id') + final String? organizationId; + @override + @JsonKey(name: 'outlet_id') + final String? outletId; + @override + @JsonKey(name: 'outlet_name') + final String? outletName; + @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 PurchasingAnalyticSummaryDto? 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); + } + + final List? _ingredientData; + @override + @JsonKey(name: 'ingredient_data') + List? get ingredientData { + final value = _ingredientData; + if (value == null) return null; + if (_ingredientData is EqualUnmodifiableListView) return _ingredientData; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + final List? _vendorData; + @override + @JsonKey(name: 'vendor_data') + List? get vendorData { + final value = _vendorData; + if (value == null) return null; + if (_vendorData is EqualUnmodifiableListView) return _vendorData; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + String toString() { + return 'PurchasingAnalyticDto(organizationId: $organizationId, outletId: $outletId, outletName: $outletName, dateFrom: $dateFrom, dateTo: $dateTo, groupBy: $groupBy, summary: $summary, data: $data, ingredientData: $ingredientData, vendorData: $vendorData)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PurchasingAnalyticDtoImpl && + (identical(other.organizationId, organizationId) || + other.organizationId == organizationId) && + (identical(other.outletId, outletId) || + other.outletId == outletId) && + (identical(other.outletName, outletName) || + other.outletName == outletName) && + (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) && + const DeepCollectionEquality().equals( + other._ingredientData, + _ingredientData, + ) && + const DeepCollectionEquality().equals( + other._vendorData, + _vendorData, + )); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + organizationId, + outletId, + outletName, + dateFrom, + dateTo, + groupBy, + summary, + const DeepCollectionEquality().hash(_data), + const DeepCollectionEquality().hash(_ingredientData), + const DeepCollectionEquality().hash(_vendorData), + ); + + /// Create a copy of PurchasingAnalyticDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PurchasingAnalyticDtoImplCopyWith<_$PurchasingAnalyticDtoImpl> + get copyWith => + __$$PurchasingAnalyticDtoImplCopyWithImpl<_$PurchasingAnalyticDtoImpl>( + this, + _$identity, + ); + + @override + Map toJson() { + return _$$PurchasingAnalyticDtoImplToJson(this); + } +} + +abstract class _PurchasingAnalyticDto extends PurchasingAnalyticDto { + const factory _PurchasingAnalyticDto({ + @JsonKey(name: 'organization_id') final String? organizationId, + @JsonKey(name: 'outlet_id') final String? outletId, + @JsonKey(name: 'outlet_name') final String? outletName, + @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 PurchasingAnalyticSummaryDto? summary, + @JsonKey(name: 'data') final List? data, + @JsonKey(name: 'ingredient_data') + final List? ingredientData, + @JsonKey(name: 'vendor_data') + final List? vendorData, + }) = _$PurchasingAnalyticDtoImpl; + const _PurchasingAnalyticDto._() : super._(); + + factory _PurchasingAnalyticDto.fromJson(Map json) = + _$PurchasingAnalyticDtoImpl.fromJson; + + @override + @JsonKey(name: 'organization_id') + String? get organizationId; + @override + @JsonKey(name: 'outlet_id') + String? get outletId; + @override + @JsonKey(name: 'outlet_name') + String? get outletName; + @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') + PurchasingAnalyticSummaryDto? get summary; + @override + @JsonKey(name: 'data') + List? get data; + @override + @JsonKey(name: 'ingredient_data') + List? get ingredientData; + @override + @JsonKey(name: 'vendor_data') + List? get vendorData; + + /// Create a copy of PurchasingAnalyticDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PurchasingAnalyticDtoImplCopyWith<_$PurchasingAnalyticDtoImpl> + get copyWith => throw _privateConstructorUsedError; +} + +PurchasingAnalyticSummaryDto _$PurchasingAnalyticSummaryDtoFromJson( + Map json, +) { + return _PurchasingAnalyticSummaryDto.fromJson(json); +} + +/// @nodoc +mixin _$PurchasingAnalyticSummaryDto { + @JsonKey(name: 'total_purchases') + num? get totalPurchases => throw _privateConstructorUsedError; + @JsonKey(name: 'total_purchase_orders') + num? get totalPurchaseOrders => throw _privateConstructorUsedError; + @JsonKey(name: 'total_quantity') + num? get totalQuantity => throw _privateConstructorUsedError; + @JsonKey(name: 'average_purchase_order_value') + num? get averagePurchaseOrderValue => throw _privateConstructorUsedError; + @JsonKey(name: 'total_ingredients') + num? get totalIngredients => throw _privateConstructorUsedError; + @JsonKey(name: 'total_vendors') + num? get totalVendors => throw _privateConstructorUsedError; + + /// Serializes this PurchasingAnalyticSummaryDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PurchasingAnalyticSummaryDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PurchasingAnalyticSummaryDtoCopyWith + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PurchasingAnalyticSummaryDtoCopyWith<$Res> { + factory $PurchasingAnalyticSummaryDtoCopyWith( + PurchasingAnalyticSummaryDto value, + $Res Function(PurchasingAnalyticSummaryDto) then, + ) = + _$PurchasingAnalyticSummaryDtoCopyWithImpl< + $Res, + PurchasingAnalyticSummaryDto + >; + @useResult + $Res call({ + @JsonKey(name: 'total_purchases') num? totalPurchases, + @JsonKey(name: 'total_purchase_orders') num? totalPurchaseOrders, + @JsonKey(name: 'total_quantity') num? totalQuantity, + @JsonKey(name: 'average_purchase_order_value') + num? averagePurchaseOrderValue, + @JsonKey(name: 'total_ingredients') num? totalIngredients, + @JsonKey(name: 'total_vendors') num? totalVendors, + }); +} + +/// @nodoc +class _$PurchasingAnalyticSummaryDtoCopyWithImpl< + $Res, + $Val extends PurchasingAnalyticSummaryDto +> + implements $PurchasingAnalyticSummaryDtoCopyWith<$Res> { + _$PurchasingAnalyticSummaryDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PurchasingAnalyticSummaryDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? totalPurchases = freezed, + Object? totalPurchaseOrders = freezed, + Object? totalQuantity = freezed, + Object? averagePurchaseOrderValue = freezed, + Object? totalIngredients = freezed, + Object? totalVendors = freezed, + }) { + return _then( + _value.copyWith( + totalPurchases: freezed == totalPurchases + ? _value.totalPurchases + : totalPurchases // ignore: cast_nullable_to_non_nullable + as num?, + totalPurchaseOrders: freezed == totalPurchaseOrders + ? _value.totalPurchaseOrders + : totalPurchaseOrders // ignore: cast_nullable_to_non_nullable + as num?, + totalQuantity: freezed == totalQuantity + ? _value.totalQuantity + : totalQuantity // ignore: cast_nullable_to_non_nullable + as num?, + averagePurchaseOrderValue: freezed == averagePurchaseOrderValue + ? _value.averagePurchaseOrderValue + : averagePurchaseOrderValue // ignore: cast_nullable_to_non_nullable + as num?, + totalIngredients: freezed == totalIngredients + ? _value.totalIngredients + : totalIngredients // ignore: cast_nullable_to_non_nullable + as num?, + totalVendors: freezed == totalVendors + ? _value.totalVendors + : totalVendors // ignore: cast_nullable_to_non_nullable + as num?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PurchasingAnalyticSummaryDtoImplCopyWith<$Res> + implements $PurchasingAnalyticSummaryDtoCopyWith<$Res> { + factory _$$PurchasingAnalyticSummaryDtoImplCopyWith( + _$PurchasingAnalyticSummaryDtoImpl value, + $Res Function(_$PurchasingAnalyticSummaryDtoImpl) then, + ) = __$$PurchasingAnalyticSummaryDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: 'total_purchases') num? totalPurchases, + @JsonKey(name: 'total_purchase_orders') num? totalPurchaseOrders, + @JsonKey(name: 'total_quantity') num? totalQuantity, + @JsonKey(name: 'average_purchase_order_value') + num? averagePurchaseOrderValue, + @JsonKey(name: 'total_ingredients') num? totalIngredients, + @JsonKey(name: 'total_vendors') num? totalVendors, + }); +} + +/// @nodoc +class __$$PurchasingAnalyticSummaryDtoImplCopyWithImpl<$Res> + extends + _$PurchasingAnalyticSummaryDtoCopyWithImpl< + $Res, + _$PurchasingAnalyticSummaryDtoImpl + > + implements _$$PurchasingAnalyticSummaryDtoImplCopyWith<$Res> { + __$$PurchasingAnalyticSummaryDtoImplCopyWithImpl( + _$PurchasingAnalyticSummaryDtoImpl _value, + $Res Function(_$PurchasingAnalyticSummaryDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PurchasingAnalyticSummaryDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? totalPurchases = freezed, + Object? totalPurchaseOrders = freezed, + Object? totalQuantity = freezed, + Object? averagePurchaseOrderValue = freezed, + Object? totalIngredients = freezed, + Object? totalVendors = freezed, + }) { + return _then( + _$PurchasingAnalyticSummaryDtoImpl( + totalPurchases: freezed == totalPurchases + ? _value.totalPurchases + : totalPurchases // ignore: cast_nullable_to_non_nullable + as num?, + totalPurchaseOrders: freezed == totalPurchaseOrders + ? _value.totalPurchaseOrders + : totalPurchaseOrders // ignore: cast_nullable_to_non_nullable + as num?, + totalQuantity: freezed == totalQuantity + ? _value.totalQuantity + : totalQuantity // ignore: cast_nullable_to_non_nullable + as num?, + averagePurchaseOrderValue: freezed == averagePurchaseOrderValue + ? _value.averagePurchaseOrderValue + : averagePurchaseOrderValue // ignore: cast_nullable_to_non_nullable + as num?, + totalIngredients: freezed == totalIngredients + ? _value.totalIngredients + : totalIngredients // ignore: cast_nullable_to_non_nullable + as num?, + totalVendors: freezed == totalVendors + ? _value.totalVendors + : totalVendors // ignore: cast_nullable_to_non_nullable + as num?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$PurchasingAnalyticSummaryDtoImpl extends _PurchasingAnalyticSummaryDto { + const _$PurchasingAnalyticSummaryDtoImpl({ + @JsonKey(name: 'total_purchases') this.totalPurchases, + @JsonKey(name: 'total_purchase_orders') this.totalPurchaseOrders, + @JsonKey(name: 'total_quantity') this.totalQuantity, + @JsonKey(name: 'average_purchase_order_value') + this.averagePurchaseOrderValue, + @JsonKey(name: 'total_ingredients') this.totalIngredients, + @JsonKey(name: 'total_vendors') this.totalVendors, + }) : super._(); + + factory _$PurchasingAnalyticSummaryDtoImpl.fromJson( + Map json, + ) => _$$PurchasingAnalyticSummaryDtoImplFromJson(json); + + @override + @JsonKey(name: 'total_purchases') + final num? totalPurchases; + @override + @JsonKey(name: 'total_purchase_orders') + final num? totalPurchaseOrders; + @override + @JsonKey(name: 'total_quantity') + final num? totalQuantity; + @override + @JsonKey(name: 'average_purchase_order_value') + final num? averagePurchaseOrderValue; + @override + @JsonKey(name: 'total_ingredients') + final num? totalIngredients; + @override + @JsonKey(name: 'total_vendors') + final num? totalVendors; + + @override + String toString() { + return 'PurchasingAnalyticSummaryDto(totalPurchases: $totalPurchases, totalPurchaseOrders: $totalPurchaseOrders, totalQuantity: $totalQuantity, averagePurchaseOrderValue: $averagePurchaseOrderValue, totalIngredients: $totalIngredients, totalVendors: $totalVendors)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PurchasingAnalyticSummaryDtoImpl && + (identical(other.totalPurchases, totalPurchases) || + other.totalPurchases == totalPurchases) && + (identical(other.totalPurchaseOrders, totalPurchaseOrders) || + other.totalPurchaseOrders == totalPurchaseOrders) && + (identical(other.totalQuantity, totalQuantity) || + other.totalQuantity == totalQuantity) && + (identical( + other.averagePurchaseOrderValue, + averagePurchaseOrderValue, + ) || + other.averagePurchaseOrderValue == averagePurchaseOrderValue) && + (identical(other.totalIngredients, totalIngredients) || + other.totalIngredients == totalIngredients) && + (identical(other.totalVendors, totalVendors) || + other.totalVendors == totalVendors)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + totalPurchases, + totalPurchaseOrders, + totalQuantity, + averagePurchaseOrderValue, + totalIngredients, + totalVendors, + ); + + /// Create a copy of PurchasingAnalyticSummaryDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PurchasingAnalyticSummaryDtoImplCopyWith< + _$PurchasingAnalyticSummaryDtoImpl + > + get copyWith => + __$$PurchasingAnalyticSummaryDtoImplCopyWithImpl< + _$PurchasingAnalyticSummaryDtoImpl + >(this, _$identity); + + @override + Map toJson() { + return _$$PurchasingAnalyticSummaryDtoImplToJson(this); + } +} + +abstract class _PurchasingAnalyticSummaryDto + extends PurchasingAnalyticSummaryDto { + const factory _PurchasingAnalyticSummaryDto({ + @JsonKey(name: 'total_purchases') final num? totalPurchases, + @JsonKey(name: 'total_purchase_orders') final num? totalPurchaseOrders, + @JsonKey(name: 'total_quantity') final num? totalQuantity, + @JsonKey(name: 'average_purchase_order_value') + final num? averagePurchaseOrderValue, + @JsonKey(name: 'total_ingredients') final num? totalIngredients, + @JsonKey(name: 'total_vendors') final num? totalVendors, + }) = _$PurchasingAnalyticSummaryDtoImpl; + const _PurchasingAnalyticSummaryDto._() : super._(); + + factory _PurchasingAnalyticSummaryDto.fromJson(Map json) = + _$PurchasingAnalyticSummaryDtoImpl.fromJson; + + @override + @JsonKey(name: 'total_purchases') + num? get totalPurchases; + @override + @JsonKey(name: 'total_purchase_orders') + num? get totalPurchaseOrders; + @override + @JsonKey(name: 'total_quantity') + num? get totalQuantity; + @override + @JsonKey(name: 'average_purchase_order_value') + num? get averagePurchaseOrderValue; + @override + @JsonKey(name: 'total_ingredients') + num? get totalIngredients; + @override + @JsonKey(name: 'total_vendors') + num? get totalVendors; + + /// Create a copy of PurchasingAnalyticSummaryDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PurchasingAnalyticSummaryDtoImplCopyWith< + _$PurchasingAnalyticSummaryDtoImpl + > + get copyWith => throw _privateConstructorUsedError; +} + +PurchasingAnalyticDataDto _$PurchasingAnalyticDataDtoFromJson( + Map json, +) { + return _PurchasingAnalyticDataDto.fromJson(json); +} + +/// @nodoc +mixin _$PurchasingAnalyticDataDto { + @JsonKey(name: 'date') + DateTime? get date => throw _privateConstructorUsedError; + @JsonKey(name: 'purchases') + num? get purchases => throw _privateConstructorUsedError; + @JsonKey(name: 'purchase_orders') + num? get purchaseOrders => throw _privateConstructorUsedError; + @JsonKey(name: 'quantity') + num? get quantity => throw _privateConstructorUsedError; + @JsonKey(name: 'ingredients') + num? get ingredients => throw _privateConstructorUsedError; + @JsonKey(name: 'vendors') + num? get vendors => throw _privateConstructorUsedError; + + /// Serializes this PurchasingAnalyticDataDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PurchasingAnalyticDataDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PurchasingAnalyticDataDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PurchasingAnalyticDataDtoCopyWith<$Res> { + factory $PurchasingAnalyticDataDtoCopyWith( + PurchasingAnalyticDataDto value, + $Res Function(PurchasingAnalyticDataDto) then, + ) = _$PurchasingAnalyticDataDtoCopyWithImpl<$Res, PurchasingAnalyticDataDto>; + @useResult + $Res call({ + @JsonKey(name: 'date') DateTime? date, + @JsonKey(name: 'purchases') num? purchases, + @JsonKey(name: 'purchase_orders') num? purchaseOrders, + @JsonKey(name: 'quantity') num? quantity, + @JsonKey(name: 'ingredients') num? ingredients, + @JsonKey(name: 'vendors') num? vendors, + }); +} + +/// @nodoc +class _$PurchasingAnalyticDataDtoCopyWithImpl< + $Res, + $Val extends PurchasingAnalyticDataDto +> + implements $PurchasingAnalyticDataDtoCopyWith<$Res> { + _$PurchasingAnalyticDataDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PurchasingAnalyticDataDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? date = freezed, + Object? purchases = freezed, + Object? purchaseOrders = freezed, + Object? quantity = freezed, + Object? ingredients = freezed, + Object? vendors = freezed, + }) { + return _then( + _value.copyWith( + date: freezed == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as DateTime?, + purchases: freezed == purchases + ? _value.purchases + : purchases // ignore: cast_nullable_to_non_nullable + as num?, + purchaseOrders: freezed == purchaseOrders + ? _value.purchaseOrders + : purchaseOrders // ignore: cast_nullable_to_non_nullable + as num?, + quantity: freezed == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as num?, + ingredients: freezed == ingredients + ? _value.ingredients + : ingredients // ignore: cast_nullable_to_non_nullable + as num?, + vendors: freezed == vendors + ? _value.vendors + : vendors // ignore: cast_nullable_to_non_nullable + as num?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PurchasingAnalyticDataDtoImplCopyWith<$Res> + implements $PurchasingAnalyticDataDtoCopyWith<$Res> { + factory _$$PurchasingAnalyticDataDtoImplCopyWith( + _$PurchasingAnalyticDataDtoImpl value, + $Res Function(_$PurchasingAnalyticDataDtoImpl) then, + ) = __$$PurchasingAnalyticDataDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: 'date') DateTime? date, + @JsonKey(name: 'purchases') num? purchases, + @JsonKey(name: 'purchase_orders') num? purchaseOrders, + @JsonKey(name: 'quantity') num? quantity, + @JsonKey(name: 'ingredients') num? ingredients, + @JsonKey(name: 'vendors') num? vendors, + }); +} + +/// @nodoc +class __$$PurchasingAnalyticDataDtoImplCopyWithImpl<$Res> + extends + _$PurchasingAnalyticDataDtoCopyWithImpl< + $Res, + _$PurchasingAnalyticDataDtoImpl + > + implements _$$PurchasingAnalyticDataDtoImplCopyWith<$Res> { + __$$PurchasingAnalyticDataDtoImplCopyWithImpl( + _$PurchasingAnalyticDataDtoImpl _value, + $Res Function(_$PurchasingAnalyticDataDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PurchasingAnalyticDataDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? date = freezed, + Object? purchases = freezed, + Object? purchaseOrders = freezed, + Object? quantity = freezed, + Object? ingredients = freezed, + Object? vendors = freezed, + }) { + return _then( + _$PurchasingAnalyticDataDtoImpl( + date: freezed == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as DateTime?, + purchases: freezed == purchases + ? _value.purchases + : purchases // ignore: cast_nullable_to_non_nullable + as num?, + purchaseOrders: freezed == purchaseOrders + ? _value.purchaseOrders + : purchaseOrders // ignore: cast_nullable_to_non_nullable + as num?, + quantity: freezed == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as num?, + ingredients: freezed == ingredients + ? _value.ingredients + : ingredients // ignore: cast_nullable_to_non_nullable + as num?, + vendors: freezed == vendors + ? _value.vendors + : vendors // ignore: cast_nullable_to_non_nullable + as num?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$PurchasingAnalyticDataDtoImpl extends _PurchasingAnalyticDataDto { + const _$PurchasingAnalyticDataDtoImpl({ + @JsonKey(name: 'date') this.date, + @JsonKey(name: 'purchases') this.purchases, + @JsonKey(name: 'purchase_orders') this.purchaseOrders, + @JsonKey(name: 'quantity') this.quantity, + @JsonKey(name: 'ingredients') this.ingredients, + @JsonKey(name: 'vendors') this.vendors, + }) : super._(); + + factory _$PurchasingAnalyticDataDtoImpl.fromJson(Map json) => + _$$PurchasingAnalyticDataDtoImplFromJson(json); + + @override + @JsonKey(name: 'date') + final DateTime? date; + @override + @JsonKey(name: 'purchases') + final num? purchases; + @override + @JsonKey(name: 'purchase_orders') + final num? purchaseOrders; + @override + @JsonKey(name: 'quantity') + final num? quantity; + @override + @JsonKey(name: 'ingredients') + final num? ingredients; + @override + @JsonKey(name: 'vendors') + final num? vendors; + + @override + String toString() { + return 'PurchasingAnalyticDataDto(date: $date, purchases: $purchases, purchaseOrders: $purchaseOrders, quantity: $quantity, ingredients: $ingredients, vendors: $vendors)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PurchasingAnalyticDataDtoImpl && + (identical(other.date, date) || other.date == date) && + (identical(other.purchases, purchases) || + other.purchases == purchases) && + (identical(other.purchaseOrders, purchaseOrders) || + other.purchaseOrders == purchaseOrders) && + (identical(other.quantity, quantity) || + other.quantity == quantity) && + (identical(other.ingredients, ingredients) || + other.ingredients == ingredients) && + (identical(other.vendors, vendors) || other.vendors == vendors)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + date, + purchases, + purchaseOrders, + quantity, + ingredients, + vendors, + ); + + /// Create a copy of PurchasingAnalyticDataDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PurchasingAnalyticDataDtoImplCopyWith<_$PurchasingAnalyticDataDtoImpl> + get copyWith => + __$$PurchasingAnalyticDataDtoImplCopyWithImpl< + _$PurchasingAnalyticDataDtoImpl + >(this, _$identity); + + @override + Map toJson() { + return _$$PurchasingAnalyticDataDtoImplToJson(this); + } +} + +abstract class _PurchasingAnalyticDataDto extends PurchasingAnalyticDataDto { + const factory _PurchasingAnalyticDataDto({ + @JsonKey(name: 'date') final DateTime? date, + @JsonKey(name: 'purchases') final num? purchases, + @JsonKey(name: 'purchase_orders') final num? purchaseOrders, + @JsonKey(name: 'quantity') final num? quantity, + @JsonKey(name: 'ingredients') final num? ingredients, + @JsonKey(name: 'vendors') final num? vendors, + }) = _$PurchasingAnalyticDataDtoImpl; + const _PurchasingAnalyticDataDto._() : super._(); + + factory _PurchasingAnalyticDataDto.fromJson(Map json) = + _$PurchasingAnalyticDataDtoImpl.fromJson; + + @override + @JsonKey(name: 'date') + DateTime? get date; + @override + @JsonKey(name: 'purchases') + num? get purchases; + @override + @JsonKey(name: 'purchase_orders') + num? get purchaseOrders; + @override + @JsonKey(name: 'quantity') + num? get quantity; + @override + @JsonKey(name: 'ingredients') + num? get ingredients; + @override + @JsonKey(name: 'vendors') + num? get vendors; + + /// Create a copy of PurchasingAnalyticDataDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PurchasingAnalyticDataDtoImplCopyWith<_$PurchasingAnalyticDataDtoImpl> + get copyWith => throw _privateConstructorUsedError; +} + +PurchasingIngredientDataDto _$PurchasingIngredientDataDtoFromJson( + Map json, +) { + return _PurchasingIngredientDataDto.fromJson(json); +} + +/// @nodoc +mixin _$PurchasingIngredientDataDto { + @JsonKey(name: 'ingredient_id') + String? get ingredientId => throw _privateConstructorUsedError; + @JsonKey(name: 'ingredient_name') + String? get ingredientName => throw _privateConstructorUsedError; + @JsonKey(name: 'quantity') + num? get quantity => throw _privateConstructorUsedError; + @JsonKey(name: 'total_cost') + num? get totalCost => throw _privateConstructorUsedError; + @JsonKey(name: 'average_unit_cost') + num? get averageUnitCost => throw _privateConstructorUsedError; + @JsonKey(name: 'purchase_order_count') + num? get purchaseOrderCount => throw _privateConstructorUsedError; + + /// Serializes this PurchasingIngredientDataDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PurchasingIngredientDataDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PurchasingIngredientDataDtoCopyWith + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PurchasingIngredientDataDtoCopyWith<$Res> { + factory $PurchasingIngredientDataDtoCopyWith( + PurchasingIngredientDataDto value, + $Res Function(PurchasingIngredientDataDto) then, + ) = + _$PurchasingIngredientDataDtoCopyWithImpl< + $Res, + PurchasingIngredientDataDto + >; + @useResult + $Res call({ + @JsonKey(name: 'ingredient_id') String? ingredientId, + @JsonKey(name: 'ingredient_name') String? ingredientName, + @JsonKey(name: 'quantity') num? quantity, + @JsonKey(name: 'total_cost') num? totalCost, + @JsonKey(name: 'average_unit_cost') num? averageUnitCost, + @JsonKey(name: 'purchase_order_count') num? purchaseOrderCount, + }); +} + +/// @nodoc +class _$PurchasingIngredientDataDtoCopyWithImpl< + $Res, + $Val extends PurchasingIngredientDataDto +> + implements $PurchasingIngredientDataDtoCopyWith<$Res> { + _$PurchasingIngredientDataDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PurchasingIngredientDataDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? ingredientId = freezed, + Object? ingredientName = freezed, + Object? quantity = freezed, + Object? totalCost = freezed, + Object? averageUnitCost = freezed, + Object? purchaseOrderCount = freezed, + }) { + return _then( + _value.copyWith( + ingredientId: freezed == ingredientId + ? _value.ingredientId + : ingredientId // ignore: cast_nullable_to_non_nullable + as String?, + ingredientName: freezed == ingredientName + ? _value.ingredientName + : ingredientName // ignore: cast_nullable_to_non_nullable + as String?, + quantity: freezed == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as num?, + totalCost: freezed == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as num?, + averageUnitCost: freezed == averageUnitCost + ? _value.averageUnitCost + : averageUnitCost // ignore: cast_nullable_to_non_nullable + as num?, + purchaseOrderCount: freezed == purchaseOrderCount + ? _value.purchaseOrderCount + : purchaseOrderCount // ignore: cast_nullable_to_non_nullable + as num?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PurchasingIngredientDataDtoImplCopyWith<$Res> + implements $PurchasingIngredientDataDtoCopyWith<$Res> { + factory _$$PurchasingIngredientDataDtoImplCopyWith( + _$PurchasingIngredientDataDtoImpl value, + $Res Function(_$PurchasingIngredientDataDtoImpl) then, + ) = __$$PurchasingIngredientDataDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: 'ingredient_id') String? ingredientId, + @JsonKey(name: 'ingredient_name') String? ingredientName, + @JsonKey(name: 'quantity') num? quantity, + @JsonKey(name: 'total_cost') num? totalCost, + @JsonKey(name: 'average_unit_cost') num? averageUnitCost, + @JsonKey(name: 'purchase_order_count') num? purchaseOrderCount, + }); +} + +/// @nodoc +class __$$PurchasingIngredientDataDtoImplCopyWithImpl<$Res> + extends + _$PurchasingIngredientDataDtoCopyWithImpl< + $Res, + _$PurchasingIngredientDataDtoImpl + > + implements _$$PurchasingIngredientDataDtoImplCopyWith<$Res> { + __$$PurchasingIngredientDataDtoImplCopyWithImpl( + _$PurchasingIngredientDataDtoImpl _value, + $Res Function(_$PurchasingIngredientDataDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PurchasingIngredientDataDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? ingredientId = freezed, + Object? ingredientName = freezed, + Object? quantity = freezed, + Object? totalCost = freezed, + Object? averageUnitCost = freezed, + Object? purchaseOrderCount = freezed, + }) { + return _then( + _$PurchasingIngredientDataDtoImpl( + ingredientId: freezed == ingredientId + ? _value.ingredientId + : ingredientId // ignore: cast_nullable_to_non_nullable + as String?, + ingredientName: freezed == ingredientName + ? _value.ingredientName + : ingredientName // ignore: cast_nullable_to_non_nullable + as String?, + quantity: freezed == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as num?, + totalCost: freezed == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as num?, + averageUnitCost: freezed == averageUnitCost + ? _value.averageUnitCost + : averageUnitCost // ignore: cast_nullable_to_non_nullable + as num?, + purchaseOrderCount: freezed == purchaseOrderCount + ? _value.purchaseOrderCount + : purchaseOrderCount // ignore: cast_nullable_to_non_nullable + as num?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$PurchasingIngredientDataDtoImpl extends _PurchasingIngredientDataDto { + const _$PurchasingIngredientDataDtoImpl({ + @JsonKey(name: 'ingredient_id') this.ingredientId, + @JsonKey(name: 'ingredient_name') this.ingredientName, + @JsonKey(name: 'quantity') this.quantity, + @JsonKey(name: 'total_cost') this.totalCost, + @JsonKey(name: 'average_unit_cost') this.averageUnitCost, + @JsonKey(name: 'purchase_order_count') this.purchaseOrderCount, + }) : super._(); + + factory _$PurchasingIngredientDataDtoImpl.fromJson( + Map json, + ) => _$$PurchasingIngredientDataDtoImplFromJson(json); + + @override + @JsonKey(name: 'ingredient_id') + final String? ingredientId; + @override + @JsonKey(name: 'ingredient_name') + final String? ingredientName; + @override + @JsonKey(name: 'quantity') + final num? quantity; + @override + @JsonKey(name: 'total_cost') + final num? totalCost; + @override + @JsonKey(name: 'average_unit_cost') + final num? averageUnitCost; + @override + @JsonKey(name: 'purchase_order_count') + final num? purchaseOrderCount; + + @override + String toString() { + return 'PurchasingIngredientDataDto(ingredientId: $ingredientId, ingredientName: $ingredientName, quantity: $quantity, totalCost: $totalCost, averageUnitCost: $averageUnitCost, purchaseOrderCount: $purchaseOrderCount)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PurchasingIngredientDataDtoImpl && + (identical(other.ingredientId, ingredientId) || + other.ingredientId == ingredientId) && + (identical(other.ingredientName, ingredientName) || + other.ingredientName == ingredientName) && + (identical(other.quantity, quantity) || + other.quantity == quantity) && + (identical(other.totalCost, totalCost) || + other.totalCost == totalCost) && + (identical(other.averageUnitCost, averageUnitCost) || + other.averageUnitCost == averageUnitCost) && + (identical(other.purchaseOrderCount, purchaseOrderCount) || + other.purchaseOrderCount == purchaseOrderCount)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + ingredientId, + ingredientName, + quantity, + totalCost, + averageUnitCost, + purchaseOrderCount, + ); + + /// Create a copy of PurchasingIngredientDataDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PurchasingIngredientDataDtoImplCopyWith<_$PurchasingIngredientDataDtoImpl> + get copyWith => + __$$PurchasingIngredientDataDtoImplCopyWithImpl< + _$PurchasingIngredientDataDtoImpl + >(this, _$identity); + + @override + Map toJson() { + return _$$PurchasingIngredientDataDtoImplToJson(this); + } +} + +abstract class _PurchasingIngredientDataDto + extends PurchasingIngredientDataDto { + const factory _PurchasingIngredientDataDto({ + @JsonKey(name: 'ingredient_id') final String? ingredientId, + @JsonKey(name: 'ingredient_name') final String? ingredientName, + @JsonKey(name: 'quantity') final num? quantity, + @JsonKey(name: 'total_cost') final num? totalCost, + @JsonKey(name: 'average_unit_cost') final num? averageUnitCost, + @JsonKey(name: 'purchase_order_count') final num? purchaseOrderCount, + }) = _$PurchasingIngredientDataDtoImpl; + const _PurchasingIngredientDataDto._() : super._(); + + factory _PurchasingIngredientDataDto.fromJson(Map json) = + _$PurchasingIngredientDataDtoImpl.fromJson; + + @override + @JsonKey(name: 'ingredient_id') + String? get ingredientId; + @override + @JsonKey(name: 'ingredient_name') + String? get ingredientName; + @override + @JsonKey(name: 'quantity') + num? get quantity; + @override + @JsonKey(name: 'total_cost') + num? get totalCost; + @override + @JsonKey(name: 'average_unit_cost') + num? get averageUnitCost; + @override + @JsonKey(name: 'purchase_order_count') + num? get purchaseOrderCount; + + /// Create a copy of PurchasingIngredientDataDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PurchasingIngredientDataDtoImplCopyWith<_$PurchasingIngredientDataDtoImpl> + get copyWith => throw _privateConstructorUsedError; +} + +PurchasingVendorDataDto _$PurchasingVendorDataDtoFromJson( + Map json, +) { + return _PurchasingVendorDataDto.fromJson(json); +} + +/// @nodoc +mixin _$PurchasingVendorDataDto { + @JsonKey(name: 'vendor_id') + String? get vendorId => throw _privateConstructorUsedError; + @JsonKey(name: 'vendor_name') + String? get vendorName => throw _privateConstructorUsedError; + @JsonKey(name: 'total_cost') + num? get totalCost => throw _privateConstructorUsedError; + @JsonKey(name: 'purchase_order_count') + num? get purchaseOrderCount => throw _privateConstructorUsedError; + @JsonKey(name: 'ingredient_count') + num? get ingredientCount => throw _privateConstructorUsedError; + @JsonKey(name: 'quantity') + num? get quantity => throw _privateConstructorUsedError; + + /// Serializes this PurchasingVendorDataDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PurchasingVendorDataDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PurchasingVendorDataDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PurchasingVendorDataDtoCopyWith<$Res> { + factory $PurchasingVendorDataDtoCopyWith( + PurchasingVendorDataDto value, + $Res Function(PurchasingVendorDataDto) then, + ) = _$PurchasingVendorDataDtoCopyWithImpl<$Res, PurchasingVendorDataDto>; + @useResult + $Res call({ + @JsonKey(name: 'vendor_id') String? vendorId, + @JsonKey(name: 'vendor_name') String? vendorName, + @JsonKey(name: 'total_cost') num? totalCost, + @JsonKey(name: 'purchase_order_count') num? purchaseOrderCount, + @JsonKey(name: 'ingredient_count') num? ingredientCount, + @JsonKey(name: 'quantity') num? quantity, + }); +} + +/// @nodoc +class _$PurchasingVendorDataDtoCopyWithImpl< + $Res, + $Val extends PurchasingVendorDataDto +> + implements $PurchasingVendorDataDtoCopyWith<$Res> { + _$PurchasingVendorDataDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PurchasingVendorDataDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? vendorId = freezed, + Object? vendorName = freezed, + Object? totalCost = freezed, + Object? purchaseOrderCount = freezed, + Object? ingredientCount = freezed, + Object? quantity = freezed, + }) { + return _then( + _value.copyWith( + vendorId: freezed == vendorId + ? _value.vendorId + : vendorId // ignore: cast_nullable_to_non_nullable + as String?, + vendorName: freezed == vendorName + ? _value.vendorName + : vendorName // ignore: cast_nullable_to_non_nullable + as String?, + totalCost: freezed == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as num?, + purchaseOrderCount: freezed == purchaseOrderCount + ? _value.purchaseOrderCount + : purchaseOrderCount // ignore: cast_nullable_to_non_nullable + as num?, + ingredientCount: freezed == ingredientCount + ? _value.ingredientCount + : ingredientCount // ignore: cast_nullable_to_non_nullable + as num?, + quantity: freezed == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as num?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PurchasingVendorDataDtoImplCopyWith<$Res> + implements $PurchasingVendorDataDtoCopyWith<$Res> { + factory _$$PurchasingVendorDataDtoImplCopyWith( + _$PurchasingVendorDataDtoImpl value, + $Res Function(_$PurchasingVendorDataDtoImpl) then, + ) = __$$PurchasingVendorDataDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: 'vendor_id') String? vendorId, + @JsonKey(name: 'vendor_name') String? vendorName, + @JsonKey(name: 'total_cost') num? totalCost, + @JsonKey(name: 'purchase_order_count') num? purchaseOrderCount, + @JsonKey(name: 'ingredient_count') num? ingredientCount, + @JsonKey(name: 'quantity') num? quantity, + }); +} + +/// @nodoc +class __$$PurchasingVendorDataDtoImplCopyWithImpl<$Res> + extends + _$PurchasingVendorDataDtoCopyWithImpl< + $Res, + _$PurchasingVendorDataDtoImpl + > + implements _$$PurchasingVendorDataDtoImplCopyWith<$Res> { + __$$PurchasingVendorDataDtoImplCopyWithImpl( + _$PurchasingVendorDataDtoImpl _value, + $Res Function(_$PurchasingVendorDataDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PurchasingVendorDataDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? vendorId = freezed, + Object? vendorName = freezed, + Object? totalCost = freezed, + Object? purchaseOrderCount = freezed, + Object? ingredientCount = freezed, + Object? quantity = freezed, + }) { + return _then( + _$PurchasingVendorDataDtoImpl( + vendorId: freezed == vendorId + ? _value.vendorId + : vendorId // ignore: cast_nullable_to_non_nullable + as String?, + vendorName: freezed == vendorName + ? _value.vendorName + : vendorName // ignore: cast_nullable_to_non_nullable + as String?, + totalCost: freezed == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as num?, + purchaseOrderCount: freezed == purchaseOrderCount + ? _value.purchaseOrderCount + : purchaseOrderCount // ignore: cast_nullable_to_non_nullable + as num?, + ingredientCount: freezed == ingredientCount + ? _value.ingredientCount + : ingredientCount // ignore: cast_nullable_to_non_nullable + as num?, + quantity: freezed == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as num?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$PurchasingVendorDataDtoImpl extends _PurchasingVendorDataDto { + const _$PurchasingVendorDataDtoImpl({ + @JsonKey(name: 'vendor_id') this.vendorId, + @JsonKey(name: 'vendor_name') this.vendorName, + @JsonKey(name: 'total_cost') this.totalCost, + @JsonKey(name: 'purchase_order_count') this.purchaseOrderCount, + @JsonKey(name: 'ingredient_count') this.ingredientCount, + @JsonKey(name: 'quantity') this.quantity, + }) : super._(); + + factory _$PurchasingVendorDataDtoImpl.fromJson(Map json) => + _$$PurchasingVendorDataDtoImplFromJson(json); + + @override + @JsonKey(name: 'vendor_id') + final String? vendorId; + @override + @JsonKey(name: 'vendor_name') + final String? vendorName; + @override + @JsonKey(name: 'total_cost') + final num? totalCost; + @override + @JsonKey(name: 'purchase_order_count') + final num? purchaseOrderCount; + @override + @JsonKey(name: 'ingredient_count') + final num? ingredientCount; + @override + @JsonKey(name: 'quantity') + final num? quantity; + + @override + String toString() { + return 'PurchasingVendorDataDto(vendorId: $vendorId, vendorName: $vendorName, totalCost: $totalCost, purchaseOrderCount: $purchaseOrderCount, ingredientCount: $ingredientCount, quantity: $quantity)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PurchasingVendorDataDtoImpl && + (identical(other.vendorId, vendorId) || + other.vendorId == vendorId) && + (identical(other.vendorName, vendorName) || + other.vendorName == vendorName) && + (identical(other.totalCost, totalCost) || + other.totalCost == totalCost) && + (identical(other.purchaseOrderCount, purchaseOrderCount) || + other.purchaseOrderCount == purchaseOrderCount) && + (identical(other.ingredientCount, ingredientCount) || + other.ingredientCount == ingredientCount) && + (identical(other.quantity, quantity) || + other.quantity == quantity)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + vendorId, + vendorName, + totalCost, + purchaseOrderCount, + ingredientCount, + quantity, + ); + + /// Create a copy of PurchasingVendorDataDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PurchasingVendorDataDtoImplCopyWith<_$PurchasingVendorDataDtoImpl> + get copyWith => + __$$PurchasingVendorDataDtoImplCopyWithImpl< + _$PurchasingVendorDataDtoImpl + >(this, _$identity); + + @override + Map toJson() { + return _$$PurchasingVendorDataDtoImplToJson(this); + } +} + +abstract class _PurchasingVendorDataDto extends PurchasingVendorDataDto { + const factory _PurchasingVendorDataDto({ + @JsonKey(name: 'vendor_id') final String? vendorId, + @JsonKey(name: 'vendor_name') final String? vendorName, + @JsonKey(name: 'total_cost') final num? totalCost, + @JsonKey(name: 'purchase_order_count') final num? purchaseOrderCount, + @JsonKey(name: 'ingredient_count') final num? ingredientCount, + @JsonKey(name: 'quantity') final num? quantity, + }) = _$PurchasingVendorDataDtoImpl; + const _PurchasingVendorDataDto._() : super._(); + + factory _PurchasingVendorDataDto.fromJson(Map json) = + _$PurchasingVendorDataDtoImpl.fromJson; + + @override + @JsonKey(name: 'vendor_id') + String? get vendorId; + @override + @JsonKey(name: 'vendor_name') + String? get vendorName; + @override + @JsonKey(name: 'total_cost') + num? get totalCost; + @override + @JsonKey(name: 'purchase_order_count') + num? get purchaseOrderCount; + @override + @JsonKey(name: 'ingredient_count') + num? get ingredientCount; + @override + @JsonKey(name: 'quantity') + num? get quantity; + + /// Create a copy of PurchasingVendorDataDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PurchasingVendorDataDtoImplCopyWith<_$PurchasingVendorDataDtoImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/infrastructure/analytic/analytic_dtos.g.dart b/lib/infrastructure/analytic/analytic_dtos.g.dart index fbdd5a6..fb10595 100644 --- a/lib/infrastructure/analytic/analytic_dtos.g.dart +++ b/lib/infrastructure/analytic/analytic_dtos.g.dart @@ -637,3 +637,139 @@ Map _$$PaymentMethodSummaryDtoImplToJson( 'total_payments': instance.totalPayments, 'average_order_value': instance.averageOrderValue, }; + +_$PurchasingAnalyticDtoImpl _$$PurchasingAnalyticDtoImplFromJson( + Map json, +) => _$PurchasingAnalyticDtoImpl( + organizationId: json['organization_id'] as String?, + outletId: json['outlet_id'] as String?, + outletName: json['outlet_name'] 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 + : PurchasingAnalyticSummaryDto.fromJson( + json['summary'] as Map, + ), + data: (json['data'] as List?) + ?.map( + (e) => PurchasingAnalyticDataDto.fromJson(e as Map), + ) + .toList(), + ingredientData: (json['ingredient_data'] as List?) + ?.map( + (e) => PurchasingIngredientDataDto.fromJson(e as Map), + ) + .toList(), + vendorData: (json['vendor_data'] as List?) + ?.map((e) => PurchasingVendorDataDto.fromJson(e as Map)) + .toList(), +); + +Map _$$PurchasingAnalyticDtoImplToJson( + _$PurchasingAnalyticDtoImpl instance, +) => { + 'organization_id': instance.organizationId, + 'outlet_id': instance.outletId, + 'outlet_name': instance.outletName, + 'date_from': instance.dateFrom?.toIso8601String(), + 'date_to': instance.dateTo?.toIso8601String(), + 'group_by': instance.groupBy, + 'summary': instance.summary, + 'data': instance.data, + 'ingredient_data': instance.ingredientData, + 'vendor_data': instance.vendorData, +}; + +_$PurchasingAnalyticSummaryDtoImpl _$$PurchasingAnalyticSummaryDtoImplFromJson( + Map json, +) => _$PurchasingAnalyticSummaryDtoImpl( + totalPurchases: json['total_purchases'] as num?, + totalPurchaseOrders: json['total_purchase_orders'] as num?, + totalQuantity: json['total_quantity'] as num?, + averagePurchaseOrderValue: json['average_purchase_order_value'] as num?, + totalIngredients: json['total_ingredients'] as num?, + totalVendors: json['total_vendors'] as num?, +); + +Map _$$PurchasingAnalyticSummaryDtoImplToJson( + _$PurchasingAnalyticSummaryDtoImpl instance, +) => { + 'total_purchases': instance.totalPurchases, + 'total_purchase_orders': instance.totalPurchaseOrders, + 'total_quantity': instance.totalQuantity, + 'average_purchase_order_value': instance.averagePurchaseOrderValue, + 'total_ingredients': instance.totalIngredients, + 'total_vendors': instance.totalVendors, +}; + +_$PurchasingAnalyticDataDtoImpl _$$PurchasingAnalyticDataDtoImplFromJson( + Map json, +) => _$PurchasingAnalyticDataDtoImpl( + date: json['date'] == null ? null : DateTime.parse(json['date'] as String), + purchases: json['purchases'] as num?, + purchaseOrders: json['purchase_orders'] as num?, + quantity: json['quantity'] as num?, + ingredients: json['ingredients'] as num?, + vendors: json['vendors'] as num?, +); + +Map _$$PurchasingAnalyticDataDtoImplToJson( + _$PurchasingAnalyticDataDtoImpl instance, +) => { + 'date': instance.date?.toIso8601String(), + 'purchases': instance.purchases, + 'purchase_orders': instance.purchaseOrders, + 'quantity': instance.quantity, + 'ingredients': instance.ingredients, + 'vendors': instance.vendors, +}; + +_$PurchasingIngredientDataDtoImpl _$$PurchasingIngredientDataDtoImplFromJson( + Map json, +) => _$PurchasingIngredientDataDtoImpl( + ingredientId: json['ingredient_id'] as String?, + ingredientName: json['ingredient_name'] as String?, + quantity: json['quantity'] as num?, + totalCost: json['total_cost'] as num?, + averageUnitCost: json['average_unit_cost'] as num?, + purchaseOrderCount: json['purchase_order_count'] as num?, +); + +Map _$$PurchasingIngredientDataDtoImplToJson( + _$PurchasingIngredientDataDtoImpl instance, +) => { + 'ingredient_id': instance.ingredientId, + 'ingredient_name': instance.ingredientName, + 'quantity': instance.quantity, + 'total_cost': instance.totalCost, + 'average_unit_cost': instance.averageUnitCost, + 'purchase_order_count': instance.purchaseOrderCount, +}; + +_$PurchasingVendorDataDtoImpl _$$PurchasingVendorDataDtoImplFromJson( + Map json, +) => _$PurchasingVendorDataDtoImpl( + vendorId: json['vendor_id'] as String?, + vendorName: json['vendor_name'] as String?, + totalCost: json['total_cost'] as num?, + purchaseOrderCount: json['purchase_order_count'] as num?, + ingredientCount: json['ingredient_count'] as num?, + quantity: json['quantity'] as num?, +); + +Map _$$PurchasingVendorDataDtoImplToJson( + _$PurchasingVendorDataDtoImpl instance, +) => { + 'vendor_id': instance.vendorId, + 'vendor_name': instance.vendorName, + 'total_cost': instance.totalCost, + 'purchase_order_count': instance.purchaseOrderCount, + 'ingredient_count': instance.ingredientCount, + 'quantity': instance.quantity, +}; diff --git a/lib/infrastructure/analytic/datasource/remote_data_provider.dart b/lib/infrastructure/analytic/datasource/remote_data_provider.dart index 29cf105..27d458e 100644 --- a/lib/infrastructure/analytic/datasource/remote_data_provider.dart +++ b/lib/infrastructure/analytic/datasource/remote_data_provider.dart @@ -231,4 +231,35 @@ class AnalyticRemoteDataProvider { return DC.error(AnalyticFailure.serverError(e)); } } + + Future> fetchPurchasing({ + required DateTime dateFrom, + required DateTime dateTo, + String? outletId, + }) async { + try { + final Map params = { + 'date_from': dateFrom.toServerDate, + 'date_to': dateTo.toServerDate, + }; + if (outletId != null) params['outlet_id'] = outletId; + + final response = await _apiClient.get( + ApiPath.purchasingAnalytic, + params: params, + headers: getAuthorizationHeader(), + ); + + if (response.data['data'] == null) { + return DC.error(AnalyticFailure.empty()); + } + + final dto = PurchasingAnalyticDto.fromJson(response.data['data']); + + return DC.data(dto); + } on ApiFailure catch (e, s) { + log('fetchPurchasingError', name: _logName, error: e, stackTrace: s); + return DC.error(AnalyticFailure.serverError(e)); + } + } } diff --git a/lib/infrastructure/analytic/dto/purchasing_analytic_dto.dart b/lib/infrastructure/analytic/dto/purchasing_analytic_dto.dart new file mode 100644 index 0000000..9972813 --- /dev/null +++ b/lib/infrastructure/analytic/dto/purchasing_analytic_dto.dart @@ -0,0 +1,143 @@ +part of '../analytic_dtos.dart'; + +@freezed +class PurchasingAnalyticDto with _$PurchasingAnalyticDto { + const PurchasingAnalyticDto._(); + + const factory PurchasingAnalyticDto({ + @JsonKey(name: 'organization_id') String? organizationId, + @JsonKey(name: 'outlet_id') String? outletId, + @JsonKey(name: 'outlet_name') String? outletName, + @JsonKey(name: 'date_from') DateTime? dateFrom, + @JsonKey(name: 'date_to') DateTime? dateTo, + @JsonKey(name: 'group_by') String? groupBy, + @JsonKey(name: 'summary') PurchasingAnalyticSummaryDto? summary, + @JsonKey(name: 'data') List? data, + @JsonKey(name: 'ingredient_data') + List? ingredientData, + @JsonKey(name: 'vendor_data') List? vendorData, + }) = _PurchasingAnalyticDto; + + factory PurchasingAnalyticDto.fromJson(Map json) => + _$PurchasingAnalyticDtoFromJson(json); + + PurchasingAnalytic toDomain() => PurchasingAnalytic( + organizationId: organizationId ?? '', + outletId: outletId ?? '', + outletName: outletName ?? '', + dateFrom: dateFrom ?? DateTime.fromMillisecondsSinceEpoch(0), + dateTo: dateTo ?? DateTime.fromMillisecondsSinceEpoch(0), + groupBy: groupBy ?? '', + summary: summary?.toDomain() ?? PurchasingAnalyticSummary.empty(), + data: data?.map((e) => e.toDomain()).toList() ?? [], + ingredientData: + ingredientData?.map((e) => e.toDomain()).toList() ?? [], + vendorData: vendorData?.map((e) => e.toDomain()).toList() ?? [], + ); +} + +@freezed +class PurchasingAnalyticSummaryDto with _$PurchasingAnalyticSummaryDto { + const PurchasingAnalyticSummaryDto._(); + + const factory PurchasingAnalyticSummaryDto({ + @JsonKey(name: 'total_purchases') num? totalPurchases, + @JsonKey(name: 'total_purchase_orders') num? totalPurchaseOrders, + @JsonKey(name: 'total_quantity') num? totalQuantity, + @JsonKey(name: 'average_purchase_order_value') + num? averagePurchaseOrderValue, + @JsonKey(name: 'total_ingredients') num? totalIngredients, + @JsonKey(name: 'total_vendors') num? totalVendors, + }) = _PurchasingAnalyticSummaryDto; + + factory PurchasingAnalyticSummaryDto.fromJson(Map json) => + _$PurchasingAnalyticSummaryDtoFromJson(json); + + PurchasingAnalyticSummary toDomain() => PurchasingAnalyticSummary( + totalPurchases: totalPurchases?.toInt() ?? 0, + totalPurchaseOrders: totalPurchaseOrders?.toInt() ?? 0, + totalQuantity: totalQuantity?.toInt() ?? 0, + averagePurchaseOrderValue: + averagePurchaseOrderValue?.toDouble() ?? 0, + totalIngredients: totalIngredients?.toInt() ?? 0, + totalVendors: totalVendors?.toInt() ?? 0, + ); +} + +@freezed +class PurchasingAnalyticDataDto with _$PurchasingAnalyticDataDto { + const PurchasingAnalyticDataDto._(); + + const factory PurchasingAnalyticDataDto({ + @JsonKey(name: 'date') DateTime? date, + @JsonKey(name: 'purchases') num? purchases, + @JsonKey(name: 'purchase_orders') num? purchaseOrders, + @JsonKey(name: 'quantity') num? quantity, + @JsonKey(name: 'ingredients') num? ingredients, + @JsonKey(name: 'vendors') num? vendors, + }) = _PurchasingAnalyticDataDto; + + factory PurchasingAnalyticDataDto.fromJson(Map json) => + _$PurchasingAnalyticDataDtoFromJson(json); + + PurchasingAnalyticData toDomain() => PurchasingAnalyticData( + date: date ?? DateTime.fromMillisecondsSinceEpoch(0), + purchases: purchases?.toInt() ?? 0, + purchaseOrders: purchaseOrders?.toInt() ?? 0, + quantity: quantity?.toInt() ?? 0, + ingredients: ingredients?.toInt() ?? 0, + vendors: vendors?.toInt() ?? 0, + ); +} + +@freezed +class PurchasingIngredientDataDto with _$PurchasingIngredientDataDto { + const PurchasingIngredientDataDto._(); + + const factory PurchasingIngredientDataDto({ + @JsonKey(name: 'ingredient_id') String? ingredientId, + @JsonKey(name: 'ingredient_name') String? ingredientName, + @JsonKey(name: 'quantity') num? quantity, + @JsonKey(name: 'total_cost') num? totalCost, + @JsonKey(name: 'average_unit_cost') num? averageUnitCost, + @JsonKey(name: 'purchase_order_count') num? purchaseOrderCount, + }) = _PurchasingIngredientDataDto; + + factory PurchasingIngredientDataDto.fromJson(Map json) => + _$PurchasingIngredientDataDtoFromJson(json); + + PurchasingIngredientData toDomain() => PurchasingIngredientData( + ingredientId: ingredientId ?? '', + ingredientName: ingredientName ?? '', + quantity: quantity?.toInt() ?? 0, + totalCost: totalCost?.toInt() ?? 0, + averageUnitCost: averageUnitCost?.toDouble() ?? 0, + purchaseOrderCount: purchaseOrderCount?.toInt() ?? 0, + ); +} + +@freezed +class PurchasingVendorDataDto with _$PurchasingVendorDataDto { + const PurchasingVendorDataDto._(); + + const factory PurchasingVendorDataDto({ + @JsonKey(name: 'vendor_id') String? vendorId, + @JsonKey(name: 'vendor_name') String? vendorName, + @JsonKey(name: 'total_cost') num? totalCost, + @JsonKey(name: 'purchase_order_count') num? purchaseOrderCount, + @JsonKey(name: 'ingredient_count') num? ingredientCount, + @JsonKey(name: 'quantity') num? quantity, + }) = _PurchasingVendorDataDto; + + factory PurchasingVendorDataDto.fromJson(Map json) => + _$PurchasingVendorDataDtoFromJson(json); + + PurchasingVendorData toDomain() => PurchasingVendorData( + vendorId: vendorId ?? '', + vendorName: vendorName ?? '', + totalCost: totalCost?.toInt() ?? 0, + purchaseOrderCount: purchaseOrderCount?.toInt() ?? 0, + ingredientCount: ingredientCount?.toInt() ?? 0, + quantity: quantity?.toInt() ?? 0, + ); +} diff --git a/lib/infrastructure/analytic/repositories/analytic_repository.dart b/lib/infrastructure/analytic/repositories/analytic_repository.dart index c32832e..ab97d97 100644 --- a/lib/infrastructure/analytic/repositories/analytic_repository.dart +++ b/lib/infrastructure/analytic/repositories/analytic_repository.dart @@ -176,4 +176,25 @@ class AnalyticRepository implements IAnalyticRepository { return left(const AnalyticFailure.unexpectedError()); } } + + @override + Future> getPurchasing({ + required DateTime dateFrom, + required DateTime dateTo, + String? outletId, + }) async { + try { + final result = await _dataProvider.fetchPurchasing( + dateFrom: dateFrom, + dateTo: dateTo, + outletId: _resolveOutletId(outletId), + ); + + if (result.hasError) return left(result.error!); + return right(result.data!.toDomain()); + } catch (e, s) { + log('getPurchasingError', name: _logName, error: e, stackTrace: s); + return left(const AnalyticFailure.unexpectedError()); + } + } } diff --git a/lib/injection.config.dart b/lib/injection.config.dart index e48e26d..037e8b1 100644 --- a/lib/injection.config.dart +++ b/lib/injection.config.dart @@ -21,6 +21,8 @@ import 'package:apskel_owner_flutter/application/analytic/product_analytic_loade as _i221; import 'package:apskel_owner_flutter/application/analytic/profit_loss_loader/profit_loss_loader_bloc.dart' as _i11; +import 'package:apskel_owner_flutter/application/analytic/purchasing_analytic_loader/purchasing_analytic_loader_bloc.dart' + as _i755; import 'package:apskel_owner_flutter/application/analytic/sales_loader/sales_loader_bloc.dart' as _i889; import 'package:apskel_owner_flutter/application/auth/auth_bloc.dart' as _i945; @@ -248,6 +250,9 @@ extension GetItInjectableX on _i174.GetIt { gh<_i850.OutletLocalDataProvider>(), ), ); + gh.factory<_i755.PurchasingAnalyticLoaderBloc>( + () => _i755.PurchasingAnalyticLoaderBloc(gh<_i477.IAnalyticRepository>()), + ); gh.factory<_i889.SalesLoaderBloc>( () => _i889.SalesLoaderBloc(gh<_i477.IAnalyticRepository>()), ); diff --git a/lib/presentation/pages/home/widgets/feature.dart b/lib/presentation/pages/home/widgets/feature.dart index 796db91..79a6ce1 100644 --- a/lib/presentation/pages/home/widgets/feature.dart +++ b/lib/presentation/pages/home/widgets/feature.dart @@ -56,6 +56,11 @@ class HomeFeature extends StatelessWidget { iconPath: Assets.icons.icReportProduct.path, onTap: () => context.router.push(ProductAnalyticRoute()), ), + // HomeFeatureTile( + // title: context.lang.inventory, + // iconPath: Assets.icons.icReportProduct.path, + // onTap: () => context.router.push(InventoryRoute()), + // ), ], ), // Row(