purchasing

This commit is contained in:
Efril
2026-05-19 23:33:12 +07:00
parent 602647ff26
commit 823e009121
16 changed files with 1536 additions and 564 deletions
@@ -28,22 +28,23 @@ class PurchasingAnalyticLoaderBloc
rangeDateChanged: (e) async {
emit(state.copyWith(dateFrom: e.dateFrom, dateTo: e.dateTo));
},
outletChanged: (e) async {
emit(state.copyWith(outletId: e.outletId));
},
fetched: (e) async {
emit(
state.copyWith(
isFetching: true,
failureOptionPurchasing: none(),
),
);
emit(state.copyWith(
isFetching: true,
failureOptionPurchasing: none(),
));
final result = await _analyticRepository.getPurchasing(
dateFrom: state.dateFrom,
dateTo: state.dateTo,
outletId: state.outletId,
);
final newState = result.fold(
(f) =>
state.copyWith(failureOptionPurchasing: optionOf(f)),
(f) => state.copyWith(failureOptionPurchasing: optionOf(f)),
(purchasing) => state.copyWith(purchasing: purchasing),
);
@@ -21,32 +21,38 @@ mixin _$PurchasingAnalyticLoaderEvent {
TResult when<TResult extends Object?>({
required TResult Function(DateTime dateFrom, DateTime dateTo)
rangeDateChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function() fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function()? fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function()? fetched,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@@ -168,6 +174,7 @@ class _$RangeDateChangedImpl implements _RangeDateChanged {
TResult when<TResult extends Object?>({
required TResult Function(DateTime dateFrom, DateTime dateTo)
rangeDateChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function() fetched,
}) {
return rangeDateChanged(dateFrom, dateTo);
@@ -177,6 +184,7 @@ class _$RangeDateChangedImpl implements _RangeDateChanged {
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function()? fetched,
}) {
return rangeDateChanged?.call(dateFrom, dateTo);
@@ -186,6 +194,7 @@ class _$RangeDateChangedImpl implements _RangeDateChanged {
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function()? fetched,
required TResult orElse(),
}) {
@@ -199,6 +208,7 @@ class _$RangeDateChangedImpl implements _RangeDateChanged {
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched,
}) {
return rangeDateChanged(this);
@@ -208,6 +218,7 @@ class _$RangeDateChangedImpl implements _RangeDateChanged {
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched,
}) {
return rangeDateChanged?.call(this);
@@ -217,6 +228,7 @@ class _$RangeDateChangedImpl implements _RangeDateChanged {
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) {
@@ -243,6 +255,157 @@ abstract class _RangeDateChanged implements PurchasingAnalyticLoaderEvent {
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$OutletChangedImplCopyWith<$Res> {
factory _$$OutletChangedImplCopyWith(
_$OutletChangedImpl value,
$Res Function(_$OutletChangedImpl) then,
) = __$$OutletChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String? outletId});
}
/// @nodoc
class __$$OutletChangedImplCopyWithImpl<$Res>
extends
_$PurchasingAnalyticLoaderEventCopyWithImpl<$Res, _$OutletChangedImpl>
implements _$$OutletChangedImplCopyWith<$Res> {
__$$OutletChangedImplCopyWithImpl(
_$OutletChangedImpl _value,
$Res Function(_$OutletChangedImpl) _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? outletId = freezed}) {
return _then(
_$OutletChangedImpl(
freezed == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String?,
),
);
}
}
/// @nodoc
class _$OutletChangedImpl implements _OutletChanged {
const _$OutletChangedImpl(this.outletId);
@override
final String? outletId;
@override
String toString() {
return 'PurchasingAnalyticLoaderEvent.outletChanged(outletId: $outletId)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$OutletChangedImpl &&
(identical(other.outletId, outletId) ||
other.outletId == outletId));
}
@override
int get hashCode => Object.hash(runtimeType, outletId);
/// 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')
_$$OutletChangedImplCopyWith<_$OutletChangedImpl> get copyWith =>
__$$OutletChangedImplCopyWithImpl<_$OutletChangedImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(DateTime dateFrom, DateTime dateTo)
rangeDateChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function() fetched,
}) {
return outletChanged(outletId);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function()? fetched,
}) {
return outletChanged?.call(outletId);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function()? fetched,
required TResult orElse(),
}) {
if (outletChanged != null) {
return outletChanged(outletId);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched,
}) {
return outletChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched,
}) {
return outletChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) {
if (outletChanged != null) {
return outletChanged(this);
}
return orElse();
}
}
abstract class _OutletChanged implements PurchasingAnalyticLoaderEvent {
const factory _OutletChanged(final String? outletId) = _$OutletChangedImpl;
String? get outletId;
/// Create a copy of PurchasingAnalyticLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$OutletChangedImplCopyWith<_$OutletChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$FetchedImplCopyWith<$Res> {
factory _$$FetchedImplCopyWith(
@@ -288,6 +451,7 @@ class _$FetchedImpl implements _Fetched {
TResult when<TResult extends Object?>({
required TResult Function(DateTime dateFrom, DateTime dateTo)
rangeDateChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function() fetched,
}) {
return fetched();
@@ -297,6 +461,7 @@ class _$FetchedImpl implements _Fetched {
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function()? fetched,
}) {
return fetched?.call();
@@ -306,6 +471,7 @@ class _$FetchedImpl implements _Fetched {
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function()? fetched,
required TResult orElse(),
}) {
@@ -319,6 +485,7 @@ class _$FetchedImpl implements _Fetched {
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched,
}) {
return fetched(this);
@@ -328,6 +495,7 @@ class _$FetchedImpl implements _Fetched {
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched,
}) {
return fetched?.call(this);
@@ -337,6 +505,7 @@ class _$FetchedImpl implements _Fetched {
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) {
@@ -359,6 +528,7 @@ mixin _$PurchasingAnalyticLoaderState {
bool get isFetching => throw _privateConstructorUsedError;
DateTime get dateFrom => throw _privateConstructorUsedError;
DateTime get dateTo => throw _privateConstructorUsedError;
String? get outletId => throw _privateConstructorUsedError;
/// Create a copy of PurchasingAnalyticLoaderState
/// with the given fields replaced by the non-null parameter values.
@@ -384,6 +554,7 @@ abstract class $PurchasingAnalyticLoaderStateCopyWith<$Res> {
bool isFetching,
DateTime dateFrom,
DateTime dateTo,
String? outletId,
});
$PurchasingAnalyticCopyWith<$Res> get purchasing;
@@ -412,6 +583,7 @@ class _$PurchasingAnalyticLoaderStateCopyWithImpl<
Object? isFetching = null,
Object? dateFrom = null,
Object? dateTo = null,
Object? outletId = freezed,
}) {
return _then(
_value.copyWith(
@@ -435,6 +607,10 @@ class _$PurchasingAnalyticLoaderStateCopyWithImpl<
? _value.dateTo
: dateTo // ignore: cast_nullable_to_non_nullable
as DateTime,
outletId: freezed == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String?,
)
as $Val,
);
@@ -466,6 +642,7 @@ abstract class _$$PurchasingAnalyticLoaderStateImplCopyWith<$Res>
bool isFetching,
DateTime dateFrom,
DateTime dateTo,
String? outletId,
});
@override
@@ -495,6 +672,7 @@ class __$$PurchasingAnalyticLoaderStateImplCopyWithImpl<$Res>
Object? isFetching = null,
Object? dateFrom = null,
Object? dateTo = null,
Object? outletId = freezed,
}) {
return _then(
_$PurchasingAnalyticLoaderStateImpl(
@@ -518,6 +696,10 @@ class __$$PurchasingAnalyticLoaderStateImplCopyWithImpl<$Res>
? _value.dateTo
: dateTo // ignore: cast_nullable_to_non_nullable
as DateTime,
outletId: freezed == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String?,
),
);
}
@@ -533,6 +715,7 @@ class _$PurchasingAnalyticLoaderStateImpl
this.isFetching = false,
required this.dateFrom,
required this.dateTo,
this.outletId,
});
@override
@@ -546,10 +729,12 @@ class _$PurchasingAnalyticLoaderStateImpl
final DateTime dateFrom;
@override
final DateTime dateTo;
@override
final String? outletId;
@override
String toString() {
return 'PurchasingAnalyticLoaderState(purchasing: $purchasing, failureOptionPurchasing: $failureOptionPurchasing, isFetching: $isFetching, dateFrom: $dateFrom, dateTo: $dateTo)';
return 'PurchasingAnalyticLoaderState(purchasing: $purchasing, failureOptionPurchasing: $failureOptionPurchasing, isFetching: $isFetching, dateFrom: $dateFrom, dateTo: $dateTo, outletId: $outletId)';
}
@override
@@ -568,7 +753,9 @@ class _$PurchasingAnalyticLoaderStateImpl
other.isFetching == isFetching) &&
(identical(other.dateFrom, dateFrom) ||
other.dateFrom == dateFrom) &&
(identical(other.dateTo, dateTo) || other.dateTo == dateTo));
(identical(other.dateTo, dateTo) || other.dateTo == dateTo) &&
(identical(other.outletId, outletId) ||
other.outletId == outletId));
}
@override
@@ -579,6 +766,7 @@ class _$PurchasingAnalyticLoaderStateImpl
isFetching,
dateFrom,
dateTo,
outletId,
);
/// Create a copy of PurchasingAnalyticLoaderState
@@ -603,6 +791,7 @@ abstract class _PurchasingAnalyticLoaderState
final bool isFetching,
required final DateTime dateFrom,
required final DateTime dateTo,
final String? outletId,
}) = _$PurchasingAnalyticLoaderStateImpl;
@override
@@ -615,6 +804,8 @@ abstract class _PurchasingAnalyticLoaderState
DateTime get dateFrom;
@override
DateTime get dateTo;
@override
String? get outletId;
/// Create a copy of PurchasingAnalyticLoaderState
/// with the given fields replaced by the non-null parameter values.
@@ -7,5 +7,9 @@ class PurchasingAnalyticLoaderEvent with _$PurchasingAnalyticLoaderEvent {
DateTime dateTo,
) = _RangeDateChanged;
const factory PurchasingAnalyticLoaderEvent.outletChanged(
String? outletId,
) = _OutletChanged;
const factory PurchasingAnalyticLoaderEvent.fetched() = _Fetched;
}
@@ -8,6 +8,7 @@ class PurchasingAnalyticLoaderState with _$PurchasingAnalyticLoaderState {
@Default(false) bool isFetching,
required DateTime dateFrom,
required DateTime dateTo,
String? outletId,
}) = _PurchasingAnalyticLoaderState;
factory PurchasingAnalyticLoaderState.initial() =>