feat: category analytic source
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
part of '../analytic_dtos.dart';
|
||||
|
||||
@freezed
|
||||
class CategoryAnalyticDto with _$CategoryAnalyticDto {
|
||||
const CategoryAnalyticDto._();
|
||||
|
||||
const factory CategoryAnalyticDto({
|
||||
@JsonKey(name: 'organization_id') String? organizationId,
|
||||
@JsonKey(name: 'outlet_id') String? outletId,
|
||||
@JsonKey(name: 'date_from') String? dateFrom,
|
||||
@JsonKey(name: 'date_to') String? dateTo,
|
||||
@JsonKey(name: 'data') List<CategoryAnalyticItemDto>? data,
|
||||
}) = _CategoryAnalyticDto;
|
||||
|
||||
factory CategoryAnalyticDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$CategoryAnalyticDtoFromJson(json);
|
||||
|
||||
CategoryAnalytic toDomain() => CategoryAnalytic(
|
||||
organizationId: organizationId ?? "",
|
||||
outletId: outletId ?? "",
|
||||
dateFrom: dateFrom ?? "",
|
||||
dateTo: dateTo ?? "",
|
||||
data: data?.map((e) => e.toDomain()).toList() ?? [],
|
||||
);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class CategoryAnalyticItemDto with _$CategoryAnalyticItemDto {
|
||||
const CategoryAnalyticItemDto._();
|
||||
|
||||
const factory CategoryAnalyticItemDto({
|
||||
@JsonKey(name: 'category_id') String? categoryId,
|
||||
@JsonKey(name: 'category_name') String? categoryName,
|
||||
@JsonKey(name: 'total_revenue') int? totalRevenue,
|
||||
@JsonKey(name: 'total_quantity') int? totalQuantity,
|
||||
@JsonKey(name: 'product_count') int? productCount,
|
||||
@JsonKey(name: 'order_count') int? orderCount,
|
||||
}) = _CategoryAnalyticItemDto;
|
||||
|
||||
factory CategoryAnalyticItemDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$CategoryAnalyticItemDtoFromJson(json);
|
||||
|
||||
CategoryAnalyticItem toDomain() => CategoryAnalyticItem(
|
||||
categoryId: categoryId ?? "",
|
||||
categoryName: categoryName ?? "",
|
||||
totalRevenue: totalRevenue ?? 0,
|
||||
totalQuantity: totalQuantity ?? 0,
|
||||
productCount: productCount ?? 0,
|
||||
orderCount: orderCount ?? 0,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user