create order
This commit is contained in:
65
lib/features/orders/data/models/order_status_model.dart
Normal file
65
lib/features/orders/data/models/order_status_model.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
/// Order Status Model
|
||||
///
|
||||
/// Data model for order status from API responses.
|
||||
library;
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:worker/features/orders/domain/entities/order_status.dart';
|
||||
|
||||
/// Order Status Model
|
||||
class OrderStatusModel extends Equatable {
|
||||
final String status;
|
||||
final String label;
|
||||
final String color;
|
||||
final int index;
|
||||
|
||||
const OrderStatusModel({
|
||||
required this.status,
|
||||
required this.label,
|
||||
required this.color,
|
||||
required this.index,
|
||||
});
|
||||
|
||||
/// Create from JSON
|
||||
factory OrderStatusModel.fromJson(Map<String, dynamic> json) {
|
||||
return OrderStatusModel(
|
||||
status: json['status'] as String,
|
||||
label: json['label'] as String,
|
||||
color: json['color'] as String,
|
||||
index: json['index'] as int,
|
||||
);
|
||||
}
|
||||
|
||||
/// Convert to JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'status': status,
|
||||
'label': label,
|
||||
'color': color,
|
||||
'index': index,
|
||||
};
|
||||
}
|
||||
|
||||
/// Convert to entity
|
||||
OrderStatus toEntity() {
|
||||
return OrderStatus(
|
||||
status: status,
|
||||
label: label,
|
||||
color: color,
|
||||
index: index,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create from entity
|
||||
factory OrderStatusModel.fromEntity(OrderStatus entity) {
|
||||
return OrderStatusModel(
|
||||
status: entity.status,
|
||||
label: entity.label,
|
||||
color: entity.color,
|
||||
index: entity.index,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [status, label, color, index];
|
||||
}
|
||||
53
lib/features/orders/data/models/payment_term_model.dart
Normal file
53
lib/features/orders/data/models/payment_term_model.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
/// Payment Term Model
|
||||
///
|
||||
/// Data model for payment term from API responses.
|
||||
library;
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:worker/features/orders/domain/entities/payment_term.dart';
|
||||
|
||||
/// Payment Term Model
|
||||
class PaymentTermModel extends Equatable {
|
||||
final String name;
|
||||
final String? customDescription;
|
||||
|
||||
const PaymentTermModel({
|
||||
required this.name,
|
||||
this.customDescription,
|
||||
});
|
||||
|
||||
/// Create from JSON
|
||||
factory PaymentTermModel.fromJson(Map<String, dynamic> json) {
|
||||
return PaymentTermModel(
|
||||
name: json['name'] as String,
|
||||
customDescription: json['custom_description'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
/// Convert to JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'name': name,
|
||||
'custom_description': customDescription,
|
||||
};
|
||||
}
|
||||
|
||||
/// Convert to entity
|
||||
PaymentTerm toEntity() {
|
||||
return PaymentTerm(
|
||||
name: name,
|
||||
customDescription: customDescription ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
/// Create from entity
|
||||
factory PaymentTermModel.fromEntity(PaymentTerm entity) {
|
||||
return PaymentTermModel(
|
||||
name: entity.name,
|
||||
customDescription: entity.customDescription,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [name, customDescription];
|
||||
}
|
||||
Reference in New Issue
Block a user