This commit is contained in:
efrilm 2025-08-13 22:11:24 +07:00
parent 670a0b6414
commit b34428965e
7 changed files with 65 additions and 51 deletions

View File

@ -59,12 +59,18 @@ class DashboardAnalyticData {
dateFrom: map['date_from'], dateFrom: map['date_from'],
dateTo: map['date_to'], dateTo: map['date_to'],
overview: DashboardOverview.fromMap(map['overview']), overview: DashboardOverview.fromMap(map['overview']),
topProducts: List<TopProduct>.from( topProducts: map['top_products'] == null
map['top_products']?.map((x) => TopProduct.fromMap(x))), ? []
paymentMethods: List<PaymentMethodAnalytic>.from(map['payment_methods'] : List<TopProduct>.from(
?.map((x) => PaymentMethodAnalytic.fromMap(x))), map['top_products']?.map((x) => TopProduct.fromMap(x))),
recentSales: List<RecentSale>.from( paymentMethods: map['payment_methods'] == null
map['recent_sales']?.map((x) => RecentSale.fromMap(x))), ? []
: List<PaymentMethodAnalytic>.from(map['payment_methods']
?.map((x) => PaymentMethodAnalytic.fromMap(x))),
recentSales: map['recent_sales'] == null
? []
: List<RecentSale>.from(
map['recent_sales']?.map((x) => RecentSale.fromMap(x))),
); );
Map<String, dynamic> toMap() => { Map<String, dynamic> toMap() => {

View File

@ -64,9 +64,12 @@ class PaymentMethodAnalyticData {
dateTo: DateTime.parse(map['date_to']), dateTo: DateTime.parse(map['date_to']),
groupBy: map['group_by'], groupBy: map['group_by'],
summary: PaymentSummary.fromMap(map['summary']), summary: PaymentSummary.fromMap(map['summary']),
data: List<PaymentMethodAnalyticItem>.from( data: map['data'] == null
map['data']?.map((x) => PaymentMethodAnalyticItem.fromMap(x)) ?? [], ? []
), : List<PaymentMethodAnalyticItem>.from(
map['data']?.map((x) => PaymentMethodAnalyticItem.fromMap(x)) ??
[],
),
); );
} }

View File

@ -52,9 +52,11 @@ class ProductAnalyticData {
outletId: map['outlet_id'], outletId: map['outlet_id'],
dateFrom: DateTime.parse(map['date_from']), dateFrom: DateTime.parse(map['date_from']),
dateTo: DateTime.parse(map['date_to']), dateTo: DateTime.parse(map['date_to']),
data: List<ProductAnalyticItem>.from( data: map['data'] == null
map['data'].map((x) => ProductAnalyticItem.fromMap(x)), ? []
), : List<ProductAnalyticItem>.from(
map['data'].map((x) => ProductAnalyticItem.fromMap(x)),
),
); );
Map<String, dynamic> toMap() => { Map<String, dynamic> toMap() => {

View File

@ -77,8 +77,8 @@ class OrderFormBloc extends Bloc<OrderFormEvent, OrderFormState> {
customerName: event.customerName, customerName: event.customerName,
notes: '', notes: '',
orderType: event.orderType.name, orderType: event.orderType.name,
tableId: event.table.id, tableId: event.table?.id ?? "",
tableNumber: event.table.tableName, tableNumber: event.table?.tableName ?? "",
outletId: userData.user?.outletId, outletId: userData.user?.outletId,
customerId: event.customer?.id ?? '', customerId: event.customer?.id ?? '',
orderItems: event.items orderItems: event.items

View File

@ -27,7 +27,7 @@ mixin _$OrderFormEvent {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -53,7 +53,7 @@ mixin _$OrderFormEvent {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -76,7 +76,7 @@ mixin _$OrderFormEvent {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -226,7 +226,7 @@ class _$StartedImpl implements _Started {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -255,7 +255,7 @@ class _$StartedImpl implements _Started {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -281,7 +281,7 @@ class _$StartedImpl implements _Started {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -496,7 +496,7 @@ class _$CreateImpl implements _Create {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -525,7 +525,7 @@ class _$CreateImpl implements _Create {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -551,7 +551,7 @@ class _$CreateImpl implements _Create {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -652,7 +652,7 @@ abstract class _$$CreateWithPaymentMethodImplCopyWith<$Res> {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod}); PaymentMethod paymentMethod});
} }
@ -674,7 +674,7 @@ class __$$CreateWithPaymentMethodImplCopyWithImpl<$Res>
Object? customerName = null, Object? customerName = null,
Object? customer = freezed, Object? customer = freezed,
Object? orderType = null, Object? orderType = null,
Object? table = null, Object? table = freezed,
Object? paymentMethod = null, Object? paymentMethod = null,
}) { }) {
return _then(_$CreateWithPaymentMethodImpl( return _then(_$CreateWithPaymentMethodImpl(
@ -694,10 +694,10 @@ class __$$CreateWithPaymentMethodImplCopyWithImpl<$Res>
? _value.orderType ? _value.orderType
: orderType // ignore: cast_nullable_to_non_nullable : orderType // ignore: cast_nullable_to_non_nullable
as OrderType, as OrderType,
table: null == table table: freezed == table
? _value.table ? _value.table
: table // ignore: cast_nullable_to_non_nullable : table // ignore: cast_nullable_to_non_nullable
as TableModel, as TableModel?,
paymentMethod: null == paymentMethod paymentMethod: null == paymentMethod
? _value.paymentMethod ? _value.paymentMethod
: paymentMethod // ignore: cast_nullable_to_non_nullable : paymentMethod // ignore: cast_nullable_to_non_nullable
@ -733,7 +733,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
@override @override
final OrderType orderType; final OrderType orderType;
@override @override
final TableModel table; final TableModel? table;
@override @override
final PaymentMethod paymentMethod; final PaymentMethod paymentMethod;
@ -790,7 +790,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -820,7 +820,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -847,7 +847,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -922,7 +922,7 @@ abstract class _CreateWithPaymentMethod implements OrderFormEvent {
required final String customerName, required final String customerName,
required final Customer? customer, required final Customer? customer,
required final OrderType orderType, required final OrderType orderType,
required final TableModel table, required final TableModel? table,
required final PaymentMethod paymentMethod}) = required final PaymentMethod paymentMethod}) =
_$CreateWithPaymentMethodImpl; _$CreateWithPaymentMethodImpl;
@ -930,7 +930,7 @@ abstract class _CreateWithPaymentMethod implements OrderFormEvent {
String get customerName; String get customerName;
Customer? get customer; Customer? get customer;
OrderType get orderType; OrderType get orderType;
TableModel get table; TableModel? get table;
PaymentMethod get paymentMethod; PaymentMethod get paymentMethod;
/// Create a copy of OrderFormEvent /// Create a copy of OrderFormEvent
@ -1034,7 +1034,7 @@ class _$AddToOrderImpl implements _AddToOrder {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -1063,7 +1063,7 @@ class _$AddToOrderImpl implements _AddToOrder {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1089,7 +1089,7 @@ class _$AddToOrderImpl implements _AddToOrder {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1276,7 +1276,7 @@ class _$RefundImpl implements _Refund {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -1305,7 +1305,7 @@ class _$RefundImpl implements _Refund {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1331,7 +1331,7 @@ class _$RefundImpl implements _Refund {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1520,7 +1520,7 @@ class _$VoidOrderImpl implements _VoidOrder {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -1549,7 +1549,7 @@ class _$VoidOrderImpl implements _VoidOrder {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1575,7 +1575,7 @@ class _$VoidOrderImpl implements _VoidOrder {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1737,7 +1737,7 @@ class _$ToggleItemImpl implements _ToggleItem {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -1766,7 +1766,7 @@ class _$ToggleItemImpl implements _ToggleItem {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1792,7 +1792,7 @@ class _$ToggleItemImpl implements _ToggleItem {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1951,7 +1951,7 @@ class _$ToggleSelectAllImpl implements _ToggleSelectAll {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -1980,7 +1980,7 @@ class _$ToggleSelectAllImpl implements _ToggleSelectAll {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -2006,7 +2006,7 @@ class _$ToggleSelectAllImpl implements _ToggleSelectAll {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,

View File

@ -15,7 +15,7 @@ class OrderFormEvent with _$OrderFormEvent {
required String customerName, required String customerName,
required Customer? customer, required Customer? customer,
required OrderType orderType, required OrderType orderType,
required TableModel table, required TableModel? table,
required PaymentMethod paymentMethod, required PaymentMethod paymentMethod,
}) = _CreateWithPaymentMethod; }) = _CreateWithPaymentMethod;
const factory OrderFormEvent.addToOrder({ const factory OrderFormEvent.addToOrder({

View File

@ -1065,13 +1065,16 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
} }
context.read<OrderFormBloc>().add( context.read<OrderFormBloc>().add(
OrderFormEvent.create( OrderFormEvent
.createWithPayment(
items: items, items: items,
customerName: customerName:
customerController customerController
.text, .text,
orderType: orderType, orderType: orderType,
table: widget.table, paymentMethod:
selectedPaymentMethod!,
table: widget.table!,
customer: customer:
selectedCustomer, selectedCustomer,
), ),