dev #1
@ -8,6 +8,7 @@ import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/dashboard_analytic_response_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/payment_method_analytic_response_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/product_analytic_response_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/profit_loss_response_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/sales_analytic_response_model.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
@ -149,4 +150,38 @@ class AnalyticRemoteDatasource {
|
||||
return left('Unexpected error occurred');
|
||||
}
|
||||
}
|
||||
|
||||
Future<Either<String, ProfitLossResponseModel>> getProfitLoss({
|
||||
required DateTime dateFrom,
|
||||
required DateTime dateTo,
|
||||
}) async {
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
final headers = {
|
||||
'Authorization': 'Bearer ${authData.token}',
|
||||
'Accept': 'application/json',
|
||||
};
|
||||
|
||||
try {
|
||||
final response = await dio.get(
|
||||
'${Variables.baseUrl}/api/v1/analytics/profit-loss',
|
||||
queryParameters: {
|
||||
'date_from': DateFormat('dd-MM-yyyy').format(dateFrom),
|
||||
'date_to': DateFormat('dd-MM-yyyy').format(dateTo),
|
||||
},
|
||||
options: Options(headers: headers),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return right(ProfitLossResponseModel.fromMap(response.data));
|
||||
} else {
|
||||
return left('Terjadi Kesalahan, Coba lagi nanti.');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
log('Dio error: ${e.message}');
|
||||
return left(e.response?.data.toString() ?? e.message ?? 'Unknown error');
|
||||
} catch (e) {
|
||||
log('Unexpected error: $e');
|
||||
return left('Unexpected error occurred');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
273
lib/data/models/response/profit_loss_response_model.dart
Normal file
273
lib/data/models/response/profit_loss_response_model.dart
Normal file
@ -0,0 +1,273 @@
|
||||
class ProfitLossResponseModel {
|
||||
final bool success;
|
||||
final ProfitLossData data;
|
||||
final dynamic errors;
|
||||
|
||||
ProfitLossResponseModel({
|
||||
required this.success,
|
||||
required this.data,
|
||||
this.errors,
|
||||
});
|
||||
|
||||
/// Dari JSON ke model (misal response dari API)
|
||||
factory ProfitLossResponseModel.fromJson(Map<String, dynamic> json) {
|
||||
return ProfitLossResponseModel(
|
||||
success: json['success'],
|
||||
data: ProfitLossData.fromMap(json['data']),
|
||||
errors: json['errors'],
|
||||
);
|
||||
}
|
||||
|
||||
/// Dari model ke JSON (misal saat kirim ke API)
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'success': success,
|
||||
'data': data.toMap(),
|
||||
'errors': errors,
|
||||
};
|
||||
}
|
||||
|
||||
/// Alias dari fromJson, kadang dibutuhkan untuk naming yang konsisten
|
||||
factory ProfitLossResponseModel.fromMap(Map<String, dynamic> map) {
|
||||
return ProfitLossResponseModel(
|
||||
success: map['success'],
|
||||
data: ProfitLossData.fromMap(map['data']),
|
||||
errors: map['errors'],
|
||||
);
|
||||
}
|
||||
|
||||
/// Alias dari toJson
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'success': success,
|
||||
'data': data.toMap(),
|
||||
'errors': errors,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class ProfitLossData {
|
||||
final String organizationId;
|
||||
final String dateFrom;
|
||||
final String dateTo;
|
||||
final String groupBy;
|
||||
final ProfitLossSummary summary;
|
||||
final List<ProfitLossItem> data;
|
||||
final List<ProfitLossProduct> productData;
|
||||
|
||||
ProfitLossData({
|
||||
required this.organizationId,
|
||||
required this.dateFrom,
|
||||
required this.dateTo,
|
||||
required this.groupBy,
|
||||
required this.summary,
|
||||
required this.data,
|
||||
required this.productData,
|
||||
});
|
||||
|
||||
factory ProfitLossData.fromMap(Map<String, dynamic> map) {
|
||||
return ProfitLossData(
|
||||
organizationId: map['organization_id'],
|
||||
dateFrom: map['date_from'],
|
||||
dateTo: map['date_to'],
|
||||
groupBy: map['group_by'],
|
||||
summary: ProfitLossSummary.fromMap(map['summary']),
|
||||
data: List<ProfitLossItem>.from(
|
||||
map['data'].map((x) => ProfitLossItem.fromMap(x))),
|
||||
productData: List<ProfitLossProduct>.from(
|
||||
map['product_data'].map((x) => ProfitLossProduct.fromMap(x))),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'organization_id': organizationId,
|
||||
'date_from': dateFrom,
|
||||
'date_to': dateTo,
|
||||
'group_by': groupBy,
|
||||
'summary': summary.toMap(),
|
||||
'data': data.map((x) => x.toMap()).toList(),
|
||||
'product_data': productData.map((x) => x.toMap()).toList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class ProfitLossSummary {
|
||||
final int totalRevenue;
|
||||
final int totalCost;
|
||||
final int grossProfit;
|
||||
final double grossProfitMargin;
|
||||
final int totalTax;
|
||||
final int totalDiscount;
|
||||
final int netProfit;
|
||||
final double netProfitMargin;
|
||||
final int totalOrders;
|
||||
final int averageProfit;
|
||||
final double profitabilityRatio;
|
||||
|
||||
ProfitLossSummary({
|
||||
required this.totalRevenue,
|
||||
required this.totalCost,
|
||||
required this.grossProfit,
|
||||
required this.grossProfitMargin,
|
||||
required this.totalTax,
|
||||
required this.totalDiscount,
|
||||
required this.netProfit,
|
||||
required this.netProfitMargin,
|
||||
required this.totalOrders,
|
||||
required this.averageProfit,
|
||||
required this.profitabilityRatio,
|
||||
});
|
||||
|
||||
factory ProfitLossSummary.fromMap(Map<String, dynamic> map) {
|
||||
return ProfitLossSummary(
|
||||
totalRevenue: map['total_revenue'],
|
||||
totalCost: map['total_cost'],
|
||||
grossProfit: map['gross_profit'],
|
||||
grossProfitMargin: (map['gross_profit_margin'] as num).toDouble(),
|
||||
totalTax: map['total_tax'],
|
||||
totalDiscount: map['total_discount'],
|
||||
netProfit: map['net_profit'],
|
||||
netProfitMargin: (map['net_profit_margin'] as num).toDouble(),
|
||||
totalOrders: map['total_orders'],
|
||||
averageProfit: map['average_profit'],
|
||||
profitabilityRatio: (map['profitability_ratio'] as num).toDouble(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'total_revenue': totalRevenue,
|
||||
'total_cost': totalCost,
|
||||
'gross_profit': grossProfit,
|
||||
'gross_profit_margin': grossProfitMargin,
|
||||
'total_tax': totalTax,
|
||||
'total_discount': totalDiscount,
|
||||
'net_profit': netProfit,
|
||||
'net_profit_margin': netProfitMargin,
|
||||
'total_orders': totalOrders,
|
||||
'average_profit': averageProfit,
|
||||
'profitability_ratio': profitabilityRatio,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class ProfitLossItem {
|
||||
final String date;
|
||||
final int revenue;
|
||||
final int cost;
|
||||
final int grossProfit;
|
||||
final double grossProfitMargin;
|
||||
final int tax;
|
||||
final int discount;
|
||||
final int netProfit;
|
||||
final double netProfitMargin;
|
||||
final int orders;
|
||||
|
||||
ProfitLossItem({
|
||||
required this.date,
|
||||
required this.revenue,
|
||||
required this.cost,
|
||||
required this.grossProfit,
|
||||
required this.grossProfitMargin,
|
||||
required this.tax,
|
||||
required this.discount,
|
||||
required this.netProfit,
|
||||
required this.netProfitMargin,
|
||||
required this.orders,
|
||||
});
|
||||
|
||||
factory ProfitLossItem.fromMap(Map<String, dynamic> map) {
|
||||
return ProfitLossItem(
|
||||
date: map['date'],
|
||||
revenue: map['revenue'],
|
||||
cost: map['cost'],
|
||||
grossProfit: map['gross_profit'],
|
||||
grossProfitMargin: (map['gross_profit_margin'] as num).toDouble(),
|
||||
tax: map['tax'],
|
||||
discount: map['discount'],
|
||||
netProfit: map['net_profit'],
|
||||
netProfitMargin: (map['net_profit_margin'] as num).toDouble(),
|
||||
orders: map['orders'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'date': date,
|
||||
'revenue': revenue,
|
||||
'cost': cost,
|
||||
'gross_profit': grossProfit,
|
||||
'gross_profit_margin': grossProfitMargin,
|
||||
'tax': tax,
|
||||
'discount': discount,
|
||||
'net_profit': netProfit,
|
||||
'net_profit_margin': netProfitMargin,
|
||||
'orders': orders,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class ProfitLossProduct {
|
||||
final String productId;
|
||||
final String productName;
|
||||
final String categoryId;
|
||||
final String categoryName;
|
||||
final int quantitySold;
|
||||
final int revenue;
|
||||
final int cost;
|
||||
final int grossProfit;
|
||||
final double grossProfitMargin;
|
||||
final int averagePrice;
|
||||
final int averageCost;
|
||||
final int profitPerUnit;
|
||||
|
||||
ProfitLossProduct({
|
||||
required this.productId,
|
||||
required this.productName,
|
||||
required this.categoryId,
|
||||
required this.categoryName,
|
||||
required this.quantitySold,
|
||||
required this.revenue,
|
||||
required this.cost,
|
||||
required this.grossProfit,
|
||||
required this.grossProfitMargin,
|
||||
required this.averagePrice,
|
||||
required this.averageCost,
|
||||
required this.profitPerUnit,
|
||||
});
|
||||
|
||||
factory ProfitLossProduct.fromMap(Map<String, dynamic> map) {
|
||||
return ProfitLossProduct(
|
||||
productId: map['product_id'],
|
||||
productName: map['product_name'],
|
||||
categoryId: map['category_id'],
|
||||
categoryName: map['category_name'],
|
||||
quantitySold: map['quantity_sold'],
|
||||
revenue: map['revenue'],
|
||||
cost: map['cost'],
|
||||
grossProfit: map['gross_profit'],
|
||||
grossProfitMargin: (map['gross_profit_margin'] as num).toDouble(),
|
||||
averagePrice: map['average_price'],
|
||||
averageCost: map['average_cost'],
|
||||
profitPerUnit: map['profit_per_unit'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'product_id': productId,
|
||||
'product_name': productName,
|
||||
'category_id': categoryId,
|
||||
'category_name': categoryName,
|
||||
'quantity_sold': quantitySold,
|
||||
'revenue': revenue,
|
||||
'cost': cost,
|
||||
'gross_profit': grossProfit,
|
||||
'gross_profit_margin': grossProfitMargin,
|
||||
'average_price': averagePrice,
|
||||
'average_cost': averageCost,
|
||||
'profit_per_unit': profitPerUnit,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,7 @@ import 'package:enaklo_pos/presentation/home/bloc/outlet_loader/outlet_loader_bl
|
||||
import 'package:enaklo_pos/presentation/home/bloc/product_loader/product_loader_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/home/bloc/user_update_outlet/user_update_outlet_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/refund/bloc/refund_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/report/blocs/profit_loss/profit_loss_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/sales/blocs/order_loader/order_loader_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/sales/blocs/payment_form/payment_form_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/setting/bloc/upload_file/upload_file_bloc.dart';
|
||||
@ -191,6 +192,9 @@ class _MyAppState extends State<MyApp> {
|
||||
BlocProvider(
|
||||
create: (context) => SummaryBloc(AnalyticRemoteDatasource()),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) => ProfitLossBloc(AnalyticRemoteDatasource()),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) => ProductSalesBloc(AnalyticRemoteDatasource()),
|
||||
),
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:enaklo_pos/data/datasources/analytic_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/profit_loss_response_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'profit_loss_event.dart';
|
||||
part 'profit_loss_state.dart';
|
||||
part 'profit_loss_bloc.freezed.dart';
|
||||
|
||||
class ProfitLossBloc extends Bloc<ProfitLossEvent, ProfitLossState> {
|
||||
final AnalyticRemoteDatasource datasource;
|
||||
ProfitLossBloc(this.datasource) : super(ProfitLossState.initial()) {
|
||||
on<_GetProfitLoss>((event, emit) async {
|
||||
emit(const _Loading());
|
||||
final result = await datasource.getProfitLoss(
|
||||
dateFrom: event.startDate,
|
||||
dateTo: event.endDate,
|
||||
);
|
||||
result.fold((l) => emit(_Error(l)), (r) => emit(_Success(r.data)));
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,864 @@
|
||||
// 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 'profit_loss_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 _$ProfitLossEvent {
|
||||
DateTime get startDate => throw _privateConstructorUsedError;
|
||||
DateTime get endDate => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate)
|
||||
getProfitLoss,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? getProfitLoss,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? getProfitLoss,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_GetProfitLoss value) getProfitLoss,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_GetProfitLoss value)? getProfitLoss,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_GetProfitLoss value)? getProfitLoss,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of ProfitLossEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$ProfitLossEventCopyWith<ProfitLossEvent> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProfitLossEventCopyWith<$Res> {
|
||||
factory $ProfitLossEventCopyWith(
|
||||
ProfitLossEvent value, $Res Function(ProfitLossEvent) then) =
|
||||
_$ProfitLossEventCopyWithImpl<$Res, ProfitLossEvent>;
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProfitLossEventCopyWithImpl<$Res, $Val extends ProfitLossEvent>
|
||||
implements $ProfitLossEventCopyWith<$Res> {
|
||||
_$ProfitLossEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ProfitLossEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? startDate = null,
|
||||
Object? endDate = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$GetProfitLossImplCopyWith<$Res>
|
||||
implements $ProfitLossEventCopyWith<$Res> {
|
||||
factory _$$GetProfitLossImplCopyWith(
|
||||
_$GetProfitLossImpl value, $Res Function(_$GetProfitLossImpl) then) =
|
||||
__$$GetProfitLossImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$GetProfitLossImplCopyWithImpl<$Res>
|
||||
extends _$ProfitLossEventCopyWithImpl<$Res, _$GetProfitLossImpl>
|
||||
implements _$$GetProfitLossImplCopyWith<$Res> {
|
||||
__$$GetProfitLossImplCopyWithImpl(
|
||||
_$GetProfitLossImpl _value, $Res Function(_$GetProfitLossImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfitLossEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? startDate = null,
|
||||
Object? endDate = null,
|
||||
}) {
|
||||
return _then(_$GetProfitLossImpl(
|
||||
null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$GetProfitLossImpl implements _GetProfitLoss {
|
||||
const _$GetProfitLossImpl(this.startDate, this.endDate);
|
||||
|
||||
@override
|
||||
final DateTime startDate;
|
||||
@override
|
||||
final DateTime endDate;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfitLossEvent.getProfitLoss(startDate: $startDate, endDate: $endDate)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$GetProfitLossImpl &&
|
||||
(identical(other.startDate, startDate) ||
|
||||
other.startDate == startDate) &&
|
||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
||||
|
||||
/// Create a copy of ProfitLossEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$GetProfitLossImplCopyWith<_$GetProfitLossImpl> get copyWith =>
|
||||
__$$GetProfitLossImplCopyWithImpl<_$GetProfitLossImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate)
|
||||
getProfitLoss,
|
||||
}) {
|
||||
return getProfitLoss(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? getProfitLoss,
|
||||
}) {
|
||||
return getProfitLoss?.call(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? getProfitLoss,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (getProfitLoss != null) {
|
||||
return getProfitLoss(startDate, endDate);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_GetProfitLoss value) getProfitLoss,
|
||||
}) {
|
||||
return getProfitLoss(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_GetProfitLoss value)? getProfitLoss,
|
||||
}) {
|
||||
return getProfitLoss?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_GetProfitLoss value)? getProfitLoss,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (getProfitLoss != null) {
|
||||
return getProfitLoss(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _GetProfitLoss implements ProfitLossEvent {
|
||||
const factory _GetProfitLoss(
|
||||
final DateTime startDate, final DateTime endDate) = _$GetProfitLossImpl;
|
||||
|
||||
@override
|
||||
DateTime get startDate;
|
||||
@override
|
||||
DateTime get endDate;
|
||||
|
||||
/// Create a copy of ProfitLossEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$GetProfitLossImplCopyWith<_$GetProfitLossImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ProfitLossState {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(ProfitLossData data) success,
|
||||
required TResult Function(String message) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(ProfitLossData data)? success,
|
||||
TResult? Function(String message)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(ProfitLossData data)? success,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Success value) success,
|
||||
required TResult Function(_Error value) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Success value)? success,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Success value)? success,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProfitLossStateCopyWith<$Res> {
|
||||
factory $ProfitLossStateCopyWith(
|
||||
ProfitLossState value, $Res Function(ProfitLossState) then) =
|
||||
_$ProfitLossStateCopyWithImpl<$Res, ProfitLossState>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProfitLossStateCopyWithImpl<$Res, $Val extends ProfitLossState>
|
||||
implements $ProfitLossStateCopyWith<$Res> {
|
||||
_$ProfitLossStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ProfitLossState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$InitialImplCopyWith<$Res> {
|
||||
factory _$$InitialImplCopyWith(
|
||||
_$InitialImpl value, $Res Function(_$InitialImpl) then) =
|
||||
__$$InitialImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$InitialImplCopyWithImpl<$Res>
|
||||
extends _$ProfitLossStateCopyWithImpl<$Res, _$InitialImpl>
|
||||
implements _$$InitialImplCopyWith<$Res> {
|
||||
__$$InitialImplCopyWithImpl(
|
||||
_$InitialImpl _value, $Res Function(_$InitialImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfitLossState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$InitialImpl implements _Initial {
|
||||
const _$InitialImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfitLossState.initial()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$InitialImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(ProfitLossData data) success,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return initial();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(ProfitLossData data)? success,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return initial?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(ProfitLossData data)? success,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
return initial();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Success value) success,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return initial(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Success value)? success,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return initial?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Success value)? success,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
return initial(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Initial implements ProfitLossState {
|
||||
const factory _Initial() = _$InitialImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$LoadingImplCopyWith<$Res> {
|
||||
factory _$$LoadingImplCopyWith(
|
||||
_$LoadingImpl value, $Res Function(_$LoadingImpl) then) =
|
||||
__$$LoadingImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$LoadingImplCopyWithImpl<$Res>
|
||||
extends _$ProfitLossStateCopyWithImpl<$Res, _$LoadingImpl>
|
||||
implements _$$LoadingImplCopyWith<$Res> {
|
||||
__$$LoadingImplCopyWithImpl(
|
||||
_$LoadingImpl _value, $Res Function(_$LoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfitLossState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$LoadingImpl implements _Loading {
|
||||
const _$LoadingImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfitLossState.loading()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$LoadingImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(ProfitLossData data) success,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return loading();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(ProfitLossData data)? success,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return loading?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(ProfitLossData data)? success,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Success value) success,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return loading(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Success value)? success,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return loading?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Success value)? success,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Loading implements ProfitLossState {
|
||||
const factory _Loading() = _$LoadingImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SuccessImplCopyWith<$Res> {
|
||||
factory _$$SuccessImplCopyWith(
|
||||
_$SuccessImpl value, $Res Function(_$SuccessImpl) then) =
|
||||
__$$SuccessImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({ProfitLossData data});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SuccessImplCopyWithImpl<$Res>
|
||||
extends _$ProfitLossStateCopyWithImpl<$Res, _$SuccessImpl>
|
||||
implements _$$SuccessImplCopyWith<$Res> {
|
||||
__$$SuccessImplCopyWithImpl(
|
||||
_$SuccessImpl _value, $Res Function(_$SuccessImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfitLossState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? data = null,
|
||||
}) {
|
||||
return _then(_$SuccessImpl(
|
||||
null == data
|
||||
? _value.data
|
||||
: data // ignore: cast_nullable_to_non_nullable
|
||||
as ProfitLossData,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SuccessImpl implements _Success {
|
||||
const _$SuccessImpl(this.data);
|
||||
|
||||
@override
|
||||
final ProfitLossData data;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfitLossState.success(data: $data)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SuccessImpl &&
|
||||
(identical(other.data, data) || other.data == data));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, data);
|
||||
|
||||
/// Create a copy of ProfitLossState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SuccessImplCopyWith<_$SuccessImpl> get copyWith =>
|
||||
__$$SuccessImplCopyWithImpl<_$SuccessImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(ProfitLossData data) success,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return success(data);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(ProfitLossData data)? success,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return success?.call(data);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(ProfitLossData data)? success,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (success != null) {
|
||||
return success(data);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Success value) success,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return success(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Success value)? success,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return success?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Success value)? success,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (success != null) {
|
||||
return success(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Success implements ProfitLossState {
|
||||
const factory _Success(final ProfitLossData data) = _$SuccessImpl;
|
||||
|
||||
ProfitLossData get data;
|
||||
|
||||
/// Create a copy of ProfitLossState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$SuccessImplCopyWith<_$SuccessImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ErrorImplCopyWith<$Res> {
|
||||
factory _$$ErrorImplCopyWith(
|
||||
_$ErrorImpl value, $Res Function(_$ErrorImpl) then) =
|
||||
__$$ErrorImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String message});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ErrorImplCopyWithImpl<$Res>
|
||||
extends _$ProfitLossStateCopyWithImpl<$Res, _$ErrorImpl>
|
||||
implements _$$ErrorImplCopyWith<$Res> {
|
||||
__$$ErrorImplCopyWithImpl(
|
||||
_$ErrorImpl _value, $Res Function(_$ErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfitLossState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? message = null,
|
||||
}) {
|
||||
return _then(_$ErrorImpl(
|
||||
null == message
|
||||
? _value.message
|
||||
: message // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ErrorImpl implements _Error {
|
||||
const _$ErrorImpl(this.message);
|
||||
|
||||
@override
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfitLossState.error(message: $message)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ErrorImpl &&
|
||||
(identical(other.message, message) || other.message == message));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, message);
|
||||
|
||||
/// Create a copy of ProfitLossState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
||||
__$$ErrorImplCopyWithImpl<_$ErrorImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(ProfitLossData data) success,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return error(message);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(ProfitLossData data)? success,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return error?.call(message);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(ProfitLossData data)? success,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(message);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Success value) success,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return error(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Success value)? success,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return error?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Success value)? success,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Error implements ProfitLossState {
|
||||
const factory _Error(final String message) = _$ErrorImpl;
|
||||
|
||||
String get message;
|
||||
|
||||
/// Create a copy of ProfitLossState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
part of 'profit_loss_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class ProfitLossEvent with _$ProfitLossEvent {
|
||||
const factory ProfitLossEvent.getProfitLoss(
|
||||
DateTime startDate,
|
||||
DateTime endDate,
|
||||
) = _GetProfitLoss;
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
part of 'profit_loss_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class ProfitLossState with _$ProfitLossState {
|
||||
const factory ProfitLossState.initial() = _Initial;
|
||||
const factory ProfitLossState.loading() = _Loading;
|
||||
const factory ProfitLossState.success(ProfitLossData data) = _Success;
|
||||
const factory ProfitLossState.error(String message) = _Error;
|
||||
}
|
||||
@ -1,7 +1,9 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||
import 'package:enaklo_pos/presentation/report/blocs/profit_loss/profit_loss_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/report/widgets/dashboard_analytic_widget.dart';
|
||||
import 'package:enaklo_pos/presentation/report/widgets/profit_loss_widget.dart';
|
||||
import 'package:enaklo_pos/presentation/sales/pages/sales_page.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:enaklo_pos/core/components/custom_date_picker.dart';
|
||||
@ -191,6 +193,23 @@ class _ReportPageState extends State<ReportPage> {
|
||||
},
|
||||
isActive: selectedMenu == 4,
|
||||
),
|
||||
ReportMenu(
|
||||
label: 'Laporan untung rugi',
|
||||
subtitle: 'Laporan untung rugi penjualan.',
|
||||
icon: Icons.trending_down,
|
||||
onPressed: () {
|
||||
selectedMenu = 5;
|
||||
title = 'Laporan untung rugi';
|
||||
setState(() {});
|
||||
context.read<ProfitLossBloc>().add(
|
||||
ProfitLossEvent.getProfitLoss(
|
||||
fromDate,
|
||||
toDate,
|
||||
),
|
||||
);
|
||||
},
|
||||
isActive: selectedMenu == 5,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -318,7 +337,30 @@ class _ReportPageState extends State<ReportPage> {
|
||||
);
|
||||
},
|
||||
)
|
||||
: const SizedBox.shrink()),
|
||||
: selectedMenu == 5
|
||||
? BlocBuilder<ProfitLossBloc,
|
||||
ProfitLossState>(
|
||||
builder: (context, state) {
|
||||
return state.maybeWhen(
|
||||
orElse: () => const Center(
|
||||
child:
|
||||
CircularProgressIndicator(),
|
||||
),
|
||||
error: (message) {
|
||||
return Text(message);
|
||||
},
|
||||
success: (data) {
|
||||
return ProfitLossWidget(
|
||||
data: data,
|
||||
title: title,
|
||||
searchDateFormatted:
|
||||
searchDateFormatted,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
: const SizedBox.shrink()),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
1135
lib/presentation/report/widgets/profit_loss_widget.dart
Normal file
1135
lib/presentation/report/widgets/profit_loss_widget.dart
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user