feat: product analytic range date
This commit is contained in:
@@ -5,22 +5,22 @@ class ProductAnalyticDto with _$ProductAnalyticDto {
|
||||
const ProductAnalyticDto._();
|
||||
|
||||
const factory ProductAnalyticDto({
|
||||
@JsonKey(name: 'organization_id') required String organizationId,
|
||||
@JsonKey(name: 'outlet_id') required String outletId,
|
||||
@JsonKey(name: 'date_from') required String dateFrom,
|
||||
@JsonKey(name: 'date_to') required String dateTo,
|
||||
required List<ProductAnalyticDataDto> data,
|
||||
@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<ProductAnalyticDataDto>? data,
|
||||
}) = _ProductAnalyticDto;
|
||||
|
||||
factory ProductAnalyticDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$ProductAnalyticDtoFromJson(json);
|
||||
|
||||
ProductAnalytic toDomain() => ProductAnalytic(
|
||||
organizationId: organizationId,
|
||||
outletId: outletId,
|
||||
dateFrom: dateFrom,
|
||||
dateTo: dateTo,
|
||||
data: data.map((e) => e.toDomain()).toList(),
|
||||
organizationId: organizationId ?? "",
|
||||
outletId: outletId ?? "",
|
||||
dateFrom: dateFrom ?? "",
|
||||
dateTo: dateTo ?? "",
|
||||
data: data?.map((e) => e.toDomain()).toList() ?? [],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -29,27 +29,27 @@ class ProductAnalyticDataDto with _$ProductAnalyticDataDto {
|
||||
const ProductAnalyticDataDto._();
|
||||
|
||||
const factory ProductAnalyticDataDto({
|
||||
@JsonKey(name: 'product_id') required String productId,
|
||||
@JsonKey(name: 'product_name') required String productName,
|
||||
@JsonKey(name: 'category_id') required String categoryId,
|
||||
@JsonKey(name: 'category_name') required String categoryName,
|
||||
@JsonKey(name: 'quantity_sold') required int quantitySold,
|
||||
required double revenue,
|
||||
@JsonKey(name: 'average_price') required double averagePrice,
|
||||
@JsonKey(name: 'order_count') required int orderCount,
|
||||
@JsonKey(name: 'product_id') String? productId,
|
||||
@JsonKey(name: 'product_name') String? productName,
|
||||
@JsonKey(name: 'category_id') String? categoryId,
|
||||
@JsonKey(name: 'category_name') String? categoryName,
|
||||
@JsonKey(name: 'quantity_sold') int? quantitySold,
|
||||
@JsonKey(name: 'revenue') int? revenue,
|
||||
@JsonKey(name: 'average_price') double? averagePrice,
|
||||
@JsonKey(name: 'order_count') int? orderCount,
|
||||
}) = _ProductAnalyticDataDto;
|
||||
|
||||
factory ProductAnalyticDataDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$ProductAnalyticDataDtoFromJson(json);
|
||||
|
||||
ProductAnalyticData toDomain() => ProductAnalyticData(
|
||||
productId: productId,
|
||||
productName: productName,
|
||||
categoryId: categoryId,
|
||||
categoryName: categoryName,
|
||||
quantitySold: quantitySold,
|
||||
revenue: revenue,
|
||||
averagePrice: averagePrice,
|
||||
orderCount: orderCount,
|
||||
productId: productId ?? "",
|
||||
productName: productName ?? "",
|
||||
categoryId: categoryId ?? "",
|
||||
categoryName: categoryName ?? "",
|
||||
quantitySold: quantitySold ?? 0,
|
||||
revenue: revenue ?? 0,
|
||||
averagePrice: averagePrice ?? 0,
|
||||
orderCount: orderCount ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user