feat: transaction report

This commit is contained in:
efrilm
2025-08-19 17:39:00 +07:00
parent 1aa65d1732
commit f07d07b3a8
8 changed files with 1927 additions and 38 deletions
@@ -0,0 +1,91 @@
import 'package:dartz/dartz.dart';
import 'package:flutter_bloc/flutter_bloc.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';
import '../../../domain/outlet/outlet.dart';
part 'transaction_report_event.dart';
part 'transaction_report_state.dart';
part 'transaction_report_bloc.freezed.dart';
@injectable
class TransactionReportBloc
extends Bloc<TransactionReportEvent, TransactionReportState> {
final IAnalyticRepository _analyticRepository;
final IOutletRepository _outletRepository;
TransactionReportBloc(this._analyticRepository, this._outletRepository)
: super(TransactionReportState.initial()) {
on<TransactionReportEvent>(_onTransactionReportEvent);
}
Future<void> _onTransactionReportEvent(
TransactionReportEvent event,
Emitter<TransactionReportState> emit,
) {
return event.map(
fetchedOutlet: (e) async {
emit(
state.copyWith(isFetchingOutlet: true, failureOptionOutlet: none()),
);
final result = await _outletRepository.currentOutlet();
var data = result.fold(
(f) => state.copyWith(failureOptionOutlet: optionOf(f)),
(currentOutlet) => state.copyWith(outlet: currentOutlet),
);
emit(data.copyWith(isFetchingOutlet: false));
},
fetchedTransaction: (e) async {
emit(state.copyWith(isFetching: true, failureOptionAnalytic: none()));
var newState = state;
final category = await _analyticRepository.getCategory(
dateFrom: e.dateFrom,
dateTo: e.dateTo,
);
final profitLoss = await _analyticRepository.getProfitLoss(
dateFrom: e.dateFrom,
dateTo: e.dateTo,
);
final paymentMethod = await _analyticRepository.getPaymentMethod(
dateFrom: e.dateFrom,
dateTo: e.dateTo,
);
final product = await _analyticRepository.getProduct(
dateFrom: e.dateFrom,
dateTo: e.dateTo,
);
newState = category.fold(
(f) => newState.copyWith(failureOptionAnalytic: optionOf(f)),
(categoryAnalytic) =>
newState.copyWith(categoryAnalytic: categoryAnalytic),
);
newState = profitLoss.fold(
(f) => newState.copyWith(failureOptionAnalytic: optionOf(f)),
(profitLossAnalytic) =>
newState.copyWith(profitLossAnalytic: profitLossAnalytic),
);
newState = paymentMethod.fold(
(f) => newState.copyWith(failureOptionAnalytic: optionOf(f)),
(paymentMethodAnalytic) =>
newState.copyWith(paymentMethodAnalytic: paymentMethodAnalytic),
);
newState = product.fold(
(f) => newState.copyWith(failureOptionAnalytic: optionOf(f)),
(productAnalytic) =>
newState.copyWith(productAnalytic: productAnalytic),
);
emit(newState.copyWith(isFetching: false));
},
);
}
}
@@ -0,0 +1,752 @@
// 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 'transaction_report_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(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 _$TransactionReportEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetchedOutlet,
required TResult Function(DateTime dateFrom, DateTime dateTo)
fetchedTransaction,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetchedOutlet,
TResult? Function(DateTime dateFrom, DateTime dateTo)? fetchedTransaction,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetchedOutlet,
TResult Function(DateTime dateFrom, DateTime dateTo)? fetchedTransaction,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_FetchedOutlet value) fetchedOutlet,
required TResult Function(_FetchedTransaction value) fetchedTransaction,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_FetchedOutlet value)? fetchedOutlet,
TResult? Function(_FetchedTransaction value)? fetchedTransaction,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_FetchedOutlet value)? fetchedOutlet,
TResult Function(_FetchedTransaction value)? fetchedTransaction,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $TransactionReportEventCopyWith<$Res> {
factory $TransactionReportEventCopyWith(
TransactionReportEvent value,
$Res Function(TransactionReportEvent) then,
) = _$TransactionReportEventCopyWithImpl<$Res, TransactionReportEvent>;
}
/// @nodoc
class _$TransactionReportEventCopyWithImpl<
$Res,
$Val extends TransactionReportEvent
>
implements $TransactionReportEventCopyWith<$Res> {
_$TransactionReportEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of TransactionReportEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$FetchedOutletImplCopyWith<$Res> {
factory _$$FetchedOutletImplCopyWith(
_$FetchedOutletImpl value,
$Res Function(_$FetchedOutletImpl) then,
) = __$$FetchedOutletImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$FetchedOutletImplCopyWithImpl<$Res>
extends _$TransactionReportEventCopyWithImpl<$Res, _$FetchedOutletImpl>
implements _$$FetchedOutletImplCopyWith<$Res> {
__$$FetchedOutletImplCopyWithImpl(
_$FetchedOutletImpl _value,
$Res Function(_$FetchedOutletImpl) _then,
) : super(_value, _then);
/// Create a copy of TransactionReportEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$FetchedOutletImpl implements _FetchedOutlet {
const _$FetchedOutletImpl();
@override
String toString() {
return 'TransactionReportEvent.fetchedOutlet()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$FetchedOutletImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetchedOutlet,
required TResult Function(DateTime dateFrom, DateTime dateTo)
fetchedTransaction,
}) {
return fetchedOutlet();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetchedOutlet,
TResult? Function(DateTime dateFrom, DateTime dateTo)? fetchedTransaction,
}) {
return fetchedOutlet?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetchedOutlet,
TResult Function(DateTime dateFrom, DateTime dateTo)? fetchedTransaction,
required TResult orElse(),
}) {
if (fetchedOutlet != null) {
return fetchedOutlet();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_FetchedOutlet value) fetchedOutlet,
required TResult Function(_FetchedTransaction value) fetchedTransaction,
}) {
return fetchedOutlet(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_FetchedOutlet value)? fetchedOutlet,
TResult? Function(_FetchedTransaction value)? fetchedTransaction,
}) {
return fetchedOutlet?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_FetchedOutlet value)? fetchedOutlet,
TResult Function(_FetchedTransaction value)? fetchedTransaction,
required TResult orElse(),
}) {
if (fetchedOutlet != null) {
return fetchedOutlet(this);
}
return orElse();
}
}
abstract class _FetchedOutlet implements TransactionReportEvent {
const factory _FetchedOutlet() = _$FetchedOutletImpl;
}
/// @nodoc
abstract class _$$FetchedTransactionImplCopyWith<$Res> {
factory _$$FetchedTransactionImplCopyWith(
_$FetchedTransactionImpl value,
$Res Function(_$FetchedTransactionImpl) then,
) = __$$FetchedTransactionImplCopyWithImpl<$Res>;
@useResult
$Res call({DateTime dateFrom, DateTime dateTo});
}
/// @nodoc
class __$$FetchedTransactionImplCopyWithImpl<$Res>
extends _$TransactionReportEventCopyWithImpl<$Res, _$FetchedTransactionImpl>
implements _$$FetchedTransactionImplCopyWith<$Res> {
__$$FetchedTransactionImplCopyWithImpl(
_$FetchedTransactionImpl _value,
$Res Function(_$FetchedTransactionImpl) _then,
) : super(_value, _then);
/// Create a copy of TransactionReportEvent
/// 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(
_$FetchedTransactionImpl(
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 _$FetchedTransactionImpl implements _FetchedTransaction {
const _$FetchedTransactionImpl(this.dateFrom, this.dateTo);
@override
final DateTime dateFrom;
@override
final DateTime dateTo;
@override
String toString() {
return 'TransactionReportEvent.fetchedTransaction(dateFrom: $dateFrom, dateTo: $dateTo)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$FetchedTransactionImpl &&
(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 TransactionReportEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$FetchedTransactionImplCopyWith<_$FetchedTransactionImpl> get copyWith =>
__$$FetchedTransactionImplCopyWithImpl<_$FetchedTransactionImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetchedOutlet,
required TResult Function(DateTime dateFrom, DateTime dateTo)
fetchedTransaction,
}) {
return fetchedTransaction(dateFrom, dateTo);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetchedOutlet,
TResult? Function(DateTime dateFrom, DateTime dateTo)? fetchedTransaction,
}) {
return fetchedTransaction?.call(dateFrom, dateTo);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetchedOutlet,
TResult Function(DateTime dateFrom, DateTime dateTo)? fetchedTransaction,
required TResult orElse(),
}) {
if (fetchedTransaction != null) {
return fetchedTransaction(dateFrom, dateTo);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_FetchedOutlet value) fetchedOutlet,
required TResult Function(_FetchedTransaction value) fetchedTransaction,
}) {
return fetchedTransaction(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_FetchedOutlet value)? fetchedOutlet,
TResult? Function(_FetchedTransaction value)? fetchedTransaction,
}) {
return fetchedTransaction?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_FetchedOutlet value)? fetchedOutlet,
TResult Function(_FetchedTransaction value)? fetchedTransaction,
required TResult orElse(),
}) {
if (fetchedTransaction != null) {
return fetchedTransaction(this);
}
return orElse();
}
}
abstract class _FetchedTransaction implements TransactionReportEvent {
const factory _FetchedTransaction(
final DateTime dateFrom,
final DateTime dateTo,
) = _$FetchedTransactionImpl;
DateTime get dateFrom;
DateTime get dateTo;
/// Create a copy of TransactionReportEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$FetchedTransactionImplCopyWith<_$FetchedTransactionImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$TransactionReportState {
CategoryAnalytic get categoryAnalytic => throw _privateConstructorUsedError;
ProfitLossAnalytic get profitLossAnalytic =>
throw _privateConstructorUsedError;
PaymentMethodAnalytic get paymentMethodAnalytic =>
throw _privateConstructorUsedError;
ProductAnalytic get productAnalytic => throw _privateConstructorUsedError;
Option<AnalyticFailure> get failureOptionAnalytic =>
throw _privateConstructorUsedError;
Outlet get outlet => throw _privateConstructorUsedError;
Option<OutletFailure> get failureOptionOutlet =>
throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError;
bool get isFetchingOutlet => throw _privateConstructorUsedError;
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$TransactionReportStateCopyWith<TransactionReportState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $TransactionReportStateCopyWith<$Res> {
factory $TransactionReportStateCopyWith(
TransactionReportState value,
$Res Function(TransactionReportState) then,
) = _$TransactionReportStateCopyWithImpl<$Res, TransactionReportState>;
@useResult
$Res call({
CategoryAnalytic categoryAnalytic,
ProfitLossAnalytic profitLossAnalytic,
PaymentMethodAnalytic paymentMethodAnalytic,
ProductAnalytic productAnalytic,
Option<AnalyticFailure> failureOptionAnalytic,
Outlet outlet,
Option<OutletFailure> failureOptionOutlet,
bool isFetching,
bool isFetchingOutlet,
});
$CategoryAnalyticCopyWith<$Res> get categoryAnalytic;
$ProfitLossAnalyticCopyWith<$Res> get profitLossAnalytic;
$PaymentMethodAnalyticCopyWith<$Res> get paymentMethodAnalytic;
$ProductAnalyticCopyWith<$Res> get productAnalytic;
$OutletCopyWith<$Res> get outlet;
}
/// @nodoc
class _$TransactionReportStateCopyWithImpl<
$Res,
$Val extends TransactionReportState
>
implements $TransactionReportStateCopyWith<$Res> {
_$TransactionReportStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? categoryAnalytic = null,
Object? profitLossAnalytic = null,
Object? paymentMethodAnalytic = null,
Object? productAnalytic = null,
Object? failureOptionAnalytic = null,
Object? outlet = null,
Object? failureOptionOutlet = null,
Object? isFetching = null,
Object? isFetchingOutlet = null,
}) {
return _then(
_value.copyWith(
categoryAnalytic: null == categoryAnalytic
? _value.categoryAnalytic
: categoryAnalytic // ignore: cast_nullable_to_non_nullable
as CategoryAnalytic,
profitLossAnalytic: null == profitLossAnalytic
? _value.profitLossAnalytic
: profitLossAnalytic // ignore: cast_nullable_to_non_nullable
as ProfitLossAnalytic,
paymentMethodAnalytic: null == paymentMethodAnalytic
? _value.paymentMethodAnalytic
: paymentMethodAnalytic // ignore: cast_nullable_to_non_nullable
as PaymentMethodAnalytic,
productAnalytic: null == productAnalytic
? _value.productAnalytic
: productAnalytic // ignore: cast_nullable_to_non_nullable
as ProductAnalytic,
failureOptionAnalytic: null == failureOptionAnalytic
? _value.failureOptionAnalytic
: failureOptionAnalytic // ignore: cast_nullable_to_non_nullable
as Option<AnalyticFailure>,
outlet: null == outlet
? _value.outlet
: outlet // ignore: cast_nullable_to_non_nullable
as Outlet,
failureOptionOutlet: null == failureOptionOutlet
? _value.failureOptionOutlet
: failureOptionOutlet // ignore: cast_nullable_to_non_nullable
as Option<OutletFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
isFetchingOutlet: null == isFetchingOutlet
? _value.isFetchingOutlet
: isFetchingOutlet // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$CategoryAnalyticCopyWith<$Res> get categoryAnalytic {
return $CategoryAnalyticCopyWith<$Res>(_value.categoryAnalytic, (value) {
return _then(_value.copyWith(categoryAnalytic: value) as $Val);
});
}
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ProfitLossAnalyticCopyWith<$Res> get profitLossAnalytic {
return $ProfitLossAnalyticCopyWith<$Res>(_value.profitLossAnalytic, (
value,
) {
return _then(_value.copyWith(profitLossAnalytic: value) as $Val);
});
}
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$PaymentMethodAnalyticCopyWith<$Res> get paymentMethodAnalytic {
return $PaymentMethodAnalyticCopyWith<$Res>(_value.paymentMethodAnalytic, (
value,
) {
return _then(_value.copyWith(paymentMethodAnalytic: value) as $Val);
});
}
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ProductAnalyticCopyWith<$Res> get productAnalytic {
return $ProductAnalyticCopyWith<$Res>(_value.productAnalytic, (value) {
return _then(_value.copyWith(productAnalytic: value) as $Val);
});
}
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$OutletCopyWith<$Res> get outlet {
return $OutletCopyWith<$Res>(_value.outlet, (value) {
return _then(_value.copyWith(outlet: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$TransactionReportStateImplCopyWith<$Res>
implements $TransactionReportStateCopyWith<$Res> {
factory _$$TransactionReportStateImplCopyWith(
_$TransactionReportStateImpl value,
$Res Function(_$TransactionReportStateImpl) then,
) = __$$TransactionReportStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
CategoryAnalytic categoryAnalytic,
ProfitLossAnalytic profitLossAnalytic,
PaymentMethodAnalytic paymentMethodAnalytic,
ProductAnalytic productAnalytic,
Option<AnalyticFailure> failureOptionAnalytic,
Outlet outlet,
Option<OutletFailure> failureOptionOutlet,
bool isFetching,
bool isFetchingOutlet,
});
@override
$CategoryAnalyticCopyWith<$Res> get categoryAnalytic;
@override
$ProfitLossAnalyticCopyWith<$Res> get profitLossAnalytic;
@override
$PaymentMethodAnalyticCopyWith<$Res> get paymentMethodAnalytic;
@override
$ProductAnalyticCopyWith<$Res> get productAnalytic;
@override
$OutletCopyWith<$Res> get outlet;
}
/// @nodoc
class __$$TransactionReportStateImplCopyWithImpl<$Res>
extends
_$TransactionReportStateCopyWithImpl<$Res, _$TransactionReportStateImpl>
implements _$$TransactionReportStateImplCopyWith<$Res> {
__$$TransactionReportStateImplCopyWithImpl(
_$TransactionReportStateImpl _value,
$Res Function(_$TransactionReportStateImpl) _then,
) : super(_value, _then);
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? categoryAnalytic = null,
Object? profitLossAnalytic = null,
Object? paymentMethodAnalytic = null,
Object? productAnalytic = null,
Object? failureOptionAnalytic = null,
Object? outlet = null,
Object? failureOptionOutlet = null,
Object? isFetching = null,
Object? isFetchingOutlet = null,
}) {
return _then(
_$TransactionReportStateImpl(
categoryAnalytic: null == categoryAnalytic
? _value.categoryAnalytic
: categoryAnalytic // ignore: cast_nullable_to_non_nullable
as CategoryAnalytic,
profitLossAnalytic: null == profitLossAnalytic
? _value.profitLossAnalytic
: profitLossAnalytic // ignore: cast_nullable_to_non_nullable
as ProfitLossAnalytic,
paymentMethodAnalytic: null == paymentMethodAnalytic
? _value.paymentMethodAnalytic
: paymentMethodAnalytic // ignore: cast_nullable_to_non_nullable
as PaymentMethodAnalytic,
productAnalytic: null == productAnalytic
? _value.productAnalytic
: productAnalytic // ignore: cast_nullable_to_non_nullable
as ProductAnalytic,
failureOptionAnalytic: null == failureOptionAnalytic
? _value.failureOptionAnalytic
: failureOptionAnalytic // ignore: cast_nullable_to_non_nullable
as Option<AnalyticFailure>,
outlet: null == outlet
? _value.outlet
: outlet // ignore: cast_nullable_to_non_nullable
as Outlet,
failureOptionOutlet: null == failureOptionOutlet
? _value.failureOptionOutlet
: failureOptionOutlet // ignore: cast_nullable_to_non_nullable
as Option<OutletFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
isFetchingOutlet: null == isFetchingOutlet
? _value.isFetchingOutlet
: isFetchingOutlet // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$TransactionReportStateImpl implements _TransactionReportState {
const _$TransactionReportStateImpl({
required this.categoryAnalytic,
required this.profitLossAnalytic,
required this.paymentMethodAnalytic,
required this.productAnalytic,
required this.failureOptionAnalytic,
required this.outlet,
required this.failureOptionOutlet,
this.isFetching = false,
this.isFetchingOutlet = false,
});
@override
final CategoryAnalytic categoryAnalytic;
@override
final ProfitLossAnalytic profitLossAnalytic;
@override
final PaymentMethodAnalytic paymentMethodAnalytic;
@override
final ProductAnalytic productAnalytic;
@override
final Option<AnalyticFailure> failureOptionAnalytic;
@override
final Outlet outlet;
@override
final Option<OutletFailure> failureOptionOutlet;
@override
@JsonKey()
final bool isFetching;
@override
@JsonKey()
final bool isFetchingOutlet;
@override
String toString() {
return 'TransactionReportState(categoryAnalytic: $categoryAnalytic, profitLossAnalytic: $profitLossAnalytic, paymentMethodAnalytic: $paymentMethodAnalytic, productAnalytic: $productAnalytic, failureOptionAnalytic: $failureOptionAnalytic, outlet: $outlet, failureOptionOutlet: $failureOptionOutlet, isFetching: $isFetching, isFetchingOutlet: $isFetchingOutlet)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$TransactionReportStateImpl &&
(identical(other.categoryAnalytic, categoryAnalytic) ||
other.categoryAnalytic == categoryAnalytic) &&
(identical(other.profitLossAnalytic, profitLossAnalytic) ||
other.profitLossAnalytic == profitLossAnalytic) &&
(identical(other.paymentMethodAnalytic, paymentMethodAnalytic) ||
other.paymentMethodAnalytic == paymentMethodAnalytic) &&
(identical(other.productAnalytic, productAnalytic) ||
other.productAnalytic == productAnalytic) &&
(identical(other.failureOptionAnalytic, failureOptionAnalytic) ||
other.failureOptionAnalytic == failureOptionAnalytic) &&
(identical(other.outlet, outlet) || other.outlet == outlet) &&
(identical(other.failureOptionOutlet, failureOptionOutlet) ||
other.failureOptionOutlet == failureOptionOutlet) &&
(identical(other.isFetching, isFetching) ||
other.isFetching == isFetching) &&
(identical(other.isFetchingOutlet, isFetchingOutlet) ||
other.isFetchingOutlet == isFetchingOutlet));
}
@override
int get hashCode => Object.hash(
runtimeType,
categoryAnalytic,
profitLossAnalytic,
paymentMethodAnalytic,
productAnalytic,
failureOptionAnalytic,
outlet,
failureOptionOutlet,
isFetching,
isFetchingOutlet,
);
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$TransactionReportStateImplCopyWith<_$TransactionReportStateImpl>
get copyWith =>
__$$TransactionReportStateImplCopyWithImpl<_$TransactionReportStateImpl>(
this,
_$identity,
);
}
abstract class _TransactionReportState implements TransactionReportState {
const factory _TransactionReportState({
required final CategoryAnalytic categoryAnalytic,
required final ProfitLossAnalytic profitLossAnalytic,
required final PaymentMethodAnalytic paymentMethodAnalytic,
required final ProductAnalytic productAnalytic,
required final Option<AnalyticFailure> failureOptionAnalytic,
required final Outlet outlet,
required final Option<OutletFailure> failureOptionOutlet,
final bool isFetching,
final bool isFetchingOutlet,
}) = _$TransactionReportStateImpl;
@override
CategoryAnalytic get categoryAnalytic;
@override
ProfitLossAnalytic get profitLossAnalytic;
@override
PaymentMethodAnalytic get paymentMethodAnalytic;
@override
ProductAnalytic get productAnalytic;
@override
Option<AnalyticFailure> get failureOptionAnalytic;
@override
Outlet get outlet;
@override
Option<OutletFailure> get failureOptionOutlet;
@override
bool get isFetching;
@override
bool get isFetchingOutlet;
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$TransactionReportStateImplCopyWith<_$TransactionReportStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
@@ -0,0 +1,10 @@
part of 'transaction_report_bloc.dart';
@freezed
class TransactionReportEvent with _$TransactionReportEvent {
const factory TransactionReportEvent.fetchedOutlet() = _FetchedOutlet;
const factory TransactionReportEvent.fetchedTransaction(
DateTime dateFrom,
DateTime dateTo,
) = _FetchedTransaction;
}
@@ -0,0 +1,26 @@
part of 'transaction_report_bloc.dart';
@freezed
class TransactionReportState with _$TransactionReportState {
const factory TransactionReportState({
required CategoryAnalytic categoryAnalytic,
required ProfitLossAnalytic profitLossAnalytic,
required PaymentMethodAnalytic paymentMethodAnalytic,
required ProductAnalytic productAnalytic,
required Option<AnalyticFailure> failureOptionAnalytic,
required Outlet outlet,
required Option<OutletFailure> failureOptionOutlet,
@Default(false) bool isFetching,
@Default(false) bool isFetchingOutlet,
}) = _TransactionReportState;
factory TransactionReportState.initial() => TransactionReportState(
failureOptionAnalytic: none(),
outlet: Outlet.empty(),
failureOptionOutlet: none(),
categoryAnalytic: CategoryAnalytic.empty(),
profitLossAnalytic: ProfitLossAnalytic.empty(),
paymentMethodAnalytic: PaymentMethodAnalytic.empty(),
productAnalytic: ProductAnalytic.empty(),
);
}