Compare commits

..

No commits in common. "3a07d2e7cc9d20e6bcef3ac6ff8d1b736cf5506f" and "b1a1303a40c659b33592bef73329a86cebc4a1f6" have entirely different histories.

4 changed files with 291 additions and 365 deletions

View File

@ -100,13 +100,10 @@ class PaymentSplitBillRequest {
Map<String, dynamic> data = { Map<String, dynamic> data = {
'order_id': orderId, 'order_id': orderId,
'payment_method_id': paymentMethodId, 'payment_method_id': paymentMethodId,
'customer_id': customerId,
'type': type, 'type': type,
}; };
if (customerId.isNotEmpty) {
data['customer_id'] = customerId;
}
if (type == "AMOUNT") { if (type == "AMOUNT") {
data['amount'] = amount; data['amount'] = amount;
} }

View File

@ -1,5 +1,35 @@
import 'dart:convert'; import 'dart:convert';
class OrderResponseModel {
final bool? success;
final OrderData? data;
final dynamic errors;
OrderResponseModel({
this.success,
this.data,
this.errors,
});
factory OrderResponseModel.fromJson(String str) =>
OrderResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory OrderResponseModel.fromMap(Map<String, dynamic> json) =>
OrderResponseModel(
success: json["success"],
data: json["data"] == null ? null : OrderData.fromMap(json["data"]),
errors: json["errors"],
);
Map<String, dynamic> toMap() => {
"success": success,
"data": data?.toMap(),
"errors": errors,
};
}
class OrderDetailResponseModel { class OrderDetailResponseModel {
final bool? success; final bool? success;
final Order? data; final Order? data;
@ -30,78 +60,41 @@ class OrderDetailResponseModel {
}; };
} }
class OrderResponseModel {
final bool? success;
final OrderData? data;
OrderResponseModel({
this.success,
this.data,
});
factory OrderResponseModel.fromJson(String str) =>
OrderResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory OrderResponseModel.fromMap(Map<String, dynamic> map) {
return OrderResponseModel(
success: map['success'] ?? false,
data: OrderData.fromMap(map['data']),
);
}
Map<String, dynamic> toMap() {
return {
'success': success,
'data': data?.toMap(),
};
}
}
class OrderData { class OrderData {
final List<Order>? orders; final List<Order>? orders;
final List<Payment>? payments;
final int? totalCount; final int? totalCount;
final int? page; final int? page;
final int? limit; final int? limit;
final int? totalPages; final int? totalPages;
OrderData({ OrderData({
required this.orders, this.orders,
required this.payments, this.totalCount,
required this.totalCount, this.page,
required this.page, this.limit,
required this.limit, this.totalPages,
required this.totalPages,
}); });
factory OrderData.fromMap(Map<String, dynamic> map) { factory OrderData.fromMap(Map<String, dynamic> json) => OrderData(
return OrderData( orders: json["orders"] == null
orders: map["orders"] == null
? [] ? []
: List<Order>.from(map['orders']?.map((x) => Order.fromMap(x))), : List<Order>.from(json["orders"].map((x) => Order.fromMap(x))),
payments: map["orders"] == null totalCount: json["total_count"],
? [] page: json["page"],
: List<Payment>.from(map['payments']?.map((x) => Payment.fromMap(x))), limit: json["limit"],
totalCount: map['total_count'], totalPages: json["total_pages"],
page: map['page'],
limit: map['limit'],
totalPages: map['total_pages'],
); );
}
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() => {
return { "orders": orders == null
'orders': orders?.map((x) => x.toMap()).toList(), ? []
'payments': payments?.map((x) => x.toMap()).toList(), : List<dynamic>.from(orders!.map((x) => x.toMap())),
'total_count': totalCount, "total_count": totalCount,
'page': page, "page": page,
'limit': limit, "limit": limit,
'total_pages': totalPages, "total_pages": totalPages,
}; };
} }
}
class Order { class Order {
final String? id; final String? id;
@ -115,20 +108,12 @@ class Order {
final int? taxAmount; final int? taxAmount;
final int? discountAmount; final int? discountAmount;
final int? totalAmount; final int? totalAmount;
final int? totalCost;
final int? remainingAmount;
final String? paymentStatus;
final int? refundAmount;
final bool? isVoid;
final bool? isRefund;
final String? notes; final String? notes;
final Map<String, dynamic>? metadata; final Map<String, dynamic>? metadata;
final DateTime? createdAt; final DateTime? createdAt;
final DateTime? updatedAt; final DateTime? updatedAt;
final List<OrderItem>? orderItems; final List<OrderItem>? orderItems;
final List<Payment>? payments; final bool? isRefund;
final int? totalPaid;
final int? paymentCount;
Order({ Order({
this.id, this.id,
@ -142,104 +127,79 @@ class Order {
this.taxAmount, this.taxAmount,
this.discountAmount, this.discountAmount,
this.totalAmount, this.totalAmount,
this.totalCost,
this.remainingAmount,
this.paymentStatus,
this.refundAmount,
this.isVoid,
this.isRefund,
this.notes, this.notes,
this.metadata, this.metadata,
this.createdAt, this.createdAt,
this.updatedAt, this.updatedAt,
this.orderItems, this.orderItems,
this.payments, this.isRefund,
this.totalPaid,
this.paymentCount,
}); });
factory Order.fromMap(Map<String, dynamic> map) { factory Order.fromMap(Map<String, dynamic> json) => Order(
return Order( id: json["id"],
id: map['id'], orderNumber: json["order_number"],
orderNumber: map['order_number'], outletId: json["outlet_id"],
outletId: map['outlet_id'], userId: json["user_id"],
userId: map['user_id'], tableNumber: json["table_number"],
tableNumber: map['table_number'], orderType: json["order_type"],
orderType: map['order_type'], status: json["status"],
status: map['status'], subtotal: json["subtotal"],
subtotal: map['subtotal'], taxAmount: json["tax_amount"],
taxAmount: map['tax_amount'], discountAmount: json["discount_amount"],
discountAmount: map['discount_amount'], totalAmount: json["total_amount"],
totalAmount: map['total_amount'], notes: json["notes"],
totalCost: map['total_cost'], metadata: json["metadata"] ?? {},
remainingAmount: map['remaining_amount'], isRefund: json["is_refund"],
paymentStatus: map['payment_status'], createdAt: json["created_at"] == null
refundAmount: map['refund_amount'], ? null
isVoid: map['is_void'], : DateTime.parse(json["created_at"]),
isRefund: map['is_refund'], updatedAt: json["updated_at"] == null
notes: map['notes'], ? null
metadata: map['metadata'] ?? {}, : DateTime.parse(json["updated_at"]),
createdAt: DateTime.parse(map['created_at']), orderItems: json["order_items"] == null
updatedAt: DateTime.parse(map['updated_at']),
orderItems: map["order_items"] == null
? [] ? []
: List<OrderItem>.from( : List<OrderItem>.from(
map['order_items'].map((x) => OrderItem.fromMap(x))), json["order_items"].map((x) => OrderItem.fromMap(x))),
payments: map["payments"] == null
? []
: List<Payment>.from(map['payments'].map((x) => Payment.fromMap(x))),
totalPaid: map['total_paid'],
paymentCount: map['payment_count'],
); );
}
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() => {
return { "id": id,
'id': id, "order_number": orderNumber,
'order_number': orderNumber, "outlet_id": outletId,
'outlet_id': outletId, "user_id": userId,
'user_id': userId, "table_number": tableNumber,
'table_number': tableNumber, "order_type": orderType,
'order_type': orderType, "status": status,
'status': status, "subtotal": subtotal,
'subtotal': subtotal, "tax_amount": taxAmount,
'tax_amount': taxAmount, "discount_amount": discountAmount,
'discount_amount': discountAmount, "total_amount": totalAmount,
'total_amount': totalAmount, "notes": notes,
'total_cost': totalCost, "metadata": metadata,
'remaining_amount': remainingAmount, "created_at": createdAt?.toIso8601String(),
'payment_status': paymentStatus, "updated_at": updatedAt?.toIso8601String(),
'refund_amount': refundAmount, "is_refund": isRefund,
'is_void': isVoid, "order_items": orderItems == null
'is_refund': isRefund, ? []
'notes': notes, : List<dynamic>.from(orderItems!.map((x) => x.toMap())),
'metadata': metadata,
'created_at': createdAt?.toIso8601String(),
'updated_at': updatedAt?.toIso8601String(),
'order_items': orderItems?.map((x) => x.toMap()).toList(),
'payments': payments?.map((x) => x.toMap()).toList(),
'total_paid': totalPaid,
'payment_count': paymentCount,
}; };
} }
}
class OrderItem { class OrderItem {
String? id; final String? id;
String? orderId; final String? orderId;
String? productId; final String? productId;
String? productName; final String? productName;
String? productVariantId; final String? productVariantId;
String? productVariantName; final String? productVariantName;
int? quantity; final int? quantity;
int? unitPrice; final int? unitPrice;
int? totalPrice; final int? totalPrice;
List<dynamic>? modifiers; final List<dynamic>? modifiers;
String? notes; final String? notes;
String? status; final String? status;
DateTime? createdAt; final DateTime? createdAt;
DateTime? updatedAt; final DateTime? updatedAt;
String? printerType;
OrderItem({ OrderItem({
this.id, this.id,
@ -256,119 +216,43 @@ class OrderItem {
this.status, this.status,
this.createdAt, this.createdAt,
this.updatedAt, this.updatedAt,
this.printerType,
}); });
factory OrderItem.fromMap(Map<String, dynamic> map) { factory OrderItem.fromMap(Map<String, dynamic> json) => OrderItem(
return OrderItem( id: json["id"],
id: map['id'], orderId: json["order_id"],
orderId: map['order_id'], productId: json["product_id"],
productId: map['product_id'], productName: json["product_name"],
productName: map['product_name'], productVariantId: json["product_variant_id"],
productVariantId: map['product_variant_id'], productVariantName: json["product_variant_name"],
productVariantName: map['product_variant_name'], quantity: json["quantity"],
quantity: map['quantity'], unitPrice: json["unit_price"],
unitPrice: map['unit_price'], totalPrice: json["total_price"],
totalPrice: map['total_price'], modifiers: json["modifiers"] ?? [],
modifiers: notes: json["notes"],
map['modifiers'] == null ? [] : List<dynamic>.from(map['modifiers']), status: json["status"],
notes: map['notes'], createdAt: json["created_at"] == null
status: map['status'], ? null
createdAt: DateTime.parse(map['created_at']), : DateTime.parse(json["created_at"]),
updatedAt: DateTime.parse(map['updated_at']), updatedAt: json["updated_at"] == null
printerType: map['printer_type'], ? null
: DateTime.parse(json["updated_at"]),
); );
}
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() => {
return { "id": id,
'id': id, "order_id": orderId,
'order_id': orderId, "product_id": productId,
'product_id': productId, "product_name": productName,
'product_name': productName, "product_variant_id": productVariantId,
'product_variant_id': productVariantId, "product_variant_name": productVariantName,
'product_variant_name': productVariantName, "quantity": quantity,
'quantity': quantity, "unit_price": unitPrice,
'unit_price': unitPrice, "total_price": totalPrice,
'total_price': totalPrice, "modifiers": modifiers,
'modifiers': modifiers, "notes": notes,
'notes': notes, "status": status,
'status': status, "created_at": createdAt?.toIso8601String(),
'created_at': createdAt?.toIso8601String(), "updated_at": updatedAt?.toIso8601String(),
'updated_at': updatedAt?.toIso8601String(),
'printer_type': printerType,
}; };
} }
}
class Payment {
final String? id;
final String? orderId;
final String? paymentMethodId;
final String? paymentMethodName;
final String? paymentMethodType;
final int? amount;
final String? status;
final int? splitNumber;
final int? splitTotal;
final String? splitDescription;
final int? refundAmount;
final Map<String, dynamic>? metadata;
final DateTime? createdAt;
final DateTime? updatedAt;
Payment({
this.id,
this.orderId,
this.paymentMethodId,
this.paymentMethodName,
this.paymentMethodType,
this.amount,
this.status,
this.splitNumber,
this.splitTotal,
this.splitDescription,
this.refundAmount,
this.metadata,
this.createdAt,
this.updatedAt,
});
factory Payment.fromMap(Map<String, dynamic> map) {
return Payment(
id: map['id'],
orderId: map['order_id'],
paymentMethodId: map['payment_method_id'],
paymentMethodName: map['payment_method_name'],
paymentMethodType: map['payment_method_type'],
amount: map['amount'],
status: map['status'],
splitNumber: map['split_number'],
splitTotal: map['split_total'],
splitDescription: map['split_description'],
refundAmount: map['refund_amount'],
metadata: map['metadata'] ?? {},
createdAt: DateTime.parse(map['created_at']),
updatedAt: DateTime.parse(map['updated_at']),
);
}
Map<String, dynamic> toMap() {
return {
'id': id,
'order_id': orderId,
'payment_method_id': paymentMethodId,
'payment_method_name': paymentMethodName,
'payment_method_type': paymentMethodType,
'amount': amount,
'status': status,
'split_number': splitNumber,
'split_total': splitTotal,
'split_description': splitDescription,
'refund_amount': refundAmount,
'metadata': metadata,
'created_at': createdAt?.toIso8601String(),
'updated_at': updatedAt?.toIso8601String(),
};
}
}

View File

@ -63,6 +63,27 @@ class SalesListOrder extends StatelessWidget {
), ),
child: Row( child: Row(
children: [ children: [
Container(
decoration: BoxDecoration(
color: AppColors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: isAllSelected ? AppColors.primary : Colors.grey.shade300,
width: 2,
),
),
child: Checkbox(
value: isAllSelected,
activeColor: AppColors.primary,
checkColor: AppColors.white,
onChanged: (val) {
context
.read<OrderFormBloc>()
.add(OrderFormEvent.toggleSelectAll(val ?? false));
},
),
),
const SizedBox(width: 12),
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -158,6 +179,28 @@ class SalesListOrder extends StatelessWidget {
Row( Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Container(
decoration: BoxDecoration(
color: AppColors.white,
borderRadius: BorderRadius.circular(6),
border: Border.all(
color:
isSelected ? AppColors.primary : Colors.grey.shade300,
width: 1.5,
),
),
child: Checkbox(
value: isSelected,
activeColor: AppColors.primary,
checkColor: AppColors.white,
onChanged: (_) {
context
.read<OrderFormBloc>()
.add(OrderFormEvent.toggleItem(product));
},
),
),
const SizedBox(width: 12),
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,

View File

@ -587,7 +587,8 @@ class _SplitBillPageState extends State<SplitBillPage> {
), ),
), ),
SizedBox(height: 16), SizedBox(height: 16),
Column( Expanded(
child: Column(
children: [ children: [
Container( Container(
padding: EdgeInsets.all(16), padding: EdgeInsets.all(16),
@ -694,6 +695,7 @@ class _SplitBillPageState extends State<SplitBillPage> {
), ),
], ],
), ),
),
], ],
); );
} }