report dashboard
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import '../../common/api/api_failure.dart';
|
||||
|
||||
part 'analytic.freezed.dart';
|
||||
|
||||
part 'entities/dashboard_entity.dart';
|
||||
part 'failures/analytic_failure.dart';
|
||||
part 'repositories/i_analytic_repository.dart';
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,118 @@
|
||||
part of '../analytic.dart';
|
||||
|
||||
@freezed
|
||||
class DashboardAnalytic with _$DashboardAnalytic {
|
||||
const factory DashboardAnalytic({
|
||||
required String organizationId,
|
||||
required String outletId,
|
||||
required String dateFrom,
|
||||
required String dateTo,
|
||||
required DashboardOverview overview,
|
||||
required List<DashboardTopProduct> topProducts,
|
||||
required List<DashboardPaymentMethod> paymentMethods,
|
||||
required List<DashboardRecentSale> recentSales,
|
||||
}) = _DashboardAnalytic;
|
||||
|
||||
factory DashboardAnalytic.empty() => DashboardAnalytic(
|
||||
organizationId: '',
|
||||
outletId: '',
|
||||
dateFrom: '',
|
||||
dateTo: '',
|
||||
overview: DashboardOverview.empty(),
|
||||
topProducts: const [],
|
||||
paymentMethods: const [],
|
||||
recentSales: const [],
|
||||
);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DashboardOverview with _$DashboardOverview {
|
||||
const factory DashboardOverview({
|
||||
required int totalSales,
|
||||
required int totalOrders,
|
||||
required double averageOrderValue,
|
||||
required int totalCustomers,
|
||||
required int voidedOrders,
|
||||
required int refundedOrders,
|
||||
}) = _DashboardOverview;
|
||||
|
||||
factory DashboardOverview.empty() => const DashboardOverview(
|
||||
totalSales: 0,
|
||||
totalOrders: 0,
|
||||
averageOrderValue: 0.0,
|
||||
totalCustomers: 0,
|
||||
voidedOrders: 0,
|
||||
refundedOrders: 0,
|
||||
);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DashboardTopProduct with _$DashboardTopProduct {
|
||||
const factory DashboardTopProduct({
|
||||
required String productId,
|
||||
required String productName,
|
||||
required String categoryId,
|
||||
required String categoryName,
|
||||
required int quantitySold,
|
||||
required int revenue,
|
||||
required double averagePrice,
|
||||
required int orderCount,
|
||||
}) = _DashboardTopProduct;
|
||||
|
||||
factory DashboardTopProduct.empty() => const DashboardTopProduct(
|
||||
productId: '',
|
||||
productName: '',
|
||||
categoryId: '',
|
||||
categoryName: '',
|
||||
quantitySold: 0,
|
||||
revenue: 0,
|
||||
averagePrice: 0.0,
|
||||
orderCount: 0,
|
||||
);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DashboardPaymentMethod with _$DashboardPaymentMethod {
|
||||
const factory DashboardPaymentMethod({
|
||||
required String paymentMethodId,
|
||||
required String paymentMethodName,
|
||||
required String paymentMethodType,
|
||||
required int totalAmount,
|
||||
required int orderCount,
|
||||
required int paymentCount,
|
||||
required double percentage,
|
||||
}) = _DashboardPaymentMethod;
|
||||
|
||||
factory DashboardPaymentMethod.empty() => const DashboardPaymentMethod(
|
||||
paymentMethodId: '',
|
||||
paymentMethodName: '',
|
||||
paymentMethodType: '',
|
||||
totalAmount: 0,
|
||||
orderCount: 0,
|
||||
paymentCount: 0,
|
||||
percentage: 0.0,
|
||||
);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DashboardRecentSale with _$DashboardRecentSale {
|
||||
const factory DashboardRecentSale({
|
||||
required String date,
|
||||
required int sales,
|
||||
required int orders,
|
||||
required int items,
|
||||
required int tax,
|
||||
required int discount,
|
||||
required int netSales,
|
||||
}) = _DashboardRecentSale;
|
||||
|
||||
factory DashboardRecentSale.empty() => const DashboardRecentSale(
|
||||
date: '',
|
||||
sales: 0,
|
||||
orders: 0,
|
||||
items: 0,
|
||||
tax: 0,
|
||||
discount: 0,
|
||||
netSales: 0,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
part of '../analytic.dart';
|
||||
|
||||
@freezed
|
||||
sealed class AnalyticFailure with _$AnalyticFailure {
|
||||
const factory AnalyticFailure.serverError(ApiFailure failure) = _ServerError;
|
||||
const factory AnalyticFailure.unexpectedError() = _UnexpectedError;
|
||||
const factory AnalyticFailure.dynamicErrorMessage(String erroMessage) =
|
||||
_DynamicErrorMessage;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
part of '../analytic.dart';
|
||||
|
||||
abstract class IAnalyticRepository {
|
||||
Future<Either<AnalyticFailure, DashboardAnalytic>> getDashboard({
|
||||
required DateTime dateFrom,
|
||||
required DateTime dateTo,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user