apskel-pos-flutter/lib/data/models/request/product_request_model.dart

52 lines
1.1 KiB
Dart
Raw Normal View History

2025-07-30 22:38:44 +07:00
class ProductRequestModel {
2025-08-03 00:35:00 +07:00
final String? id;
2025-07-30 22:38:44 +07:00
final String name;
2025-08-05 19:20:45 +07:00
final String? description;
final String categoryId;
final String? sku;
final String? barcode;
2025-07-30 22:38:44 +07:00
final int price;
2025-08-05 19:20:45 +07:00
final int cost;
final bool isActive;
final bool hasVariants;
final String imageUrl;
2025-07-30 22:38:44 +07:00
final String? printerType;
2025-08-05 19:20:45 +07:00
2025-07-30 22:38:44 +07:00
ProductRequestModel({
this.id,
required this.name,
2025-08-05 19:20:45 +07:00
this.description,
2025-07-30 22:38:44 +07:00
required this.categoryId,
2025-08-05 19:20:45 +07:00
this.sku,
this.barcode,
required this.price,
required this.cost,
this.isActive = true,
this.hasVariants = false,
required this.imageUrl,
2025-07-30 22:38:44 +07:00
this.printerType,
});
2025-08-05 19:20:45 +07:00
Map<String, dynamic> toMap() {
final map = <String, dynamic>{
2025-07-30 22:38:44 +07:00
'name': name,
2025-08-05 19:20:45 +07:00
'description': description ?? '',
'category_id': categoryId,
'sku': sku ?? '',
'barcode': barcode ?? '',
'price': price,
'cost': cost,
'is_active': isActive,
'has_variants': hasVariants,
'image_url': imageUrl,
2025-07-30 22:38:44 +07:00
'printer_type': printerType ?? '',
};
2025-08-03 00:35:00 +07:00
2025-07-30 22:38:44 +07:00
if (id != null) {
2025-08-05 19:20:45 +07:00
map['id'] = id;
2025-07-30 22:38:44 +07:00
}
2025-08-03 00:35:00 +07:00
2025-07-30 22:38:44 +07:00
return map;
}
}