feat: product variant
This commit is contained in:
@@ -5,12 +5,14 @@ import 'package:enaklo_pos/data/models/response/product_response_model.dart';
|
||||
|
||||
class ProductQuantity {
|
||||
final Product product;
|
||||
ProductVariant? variant;
|
||||
int quantity;
|
||||
String notes;
|
||||
ProductQuantity({
|
||||
required this.product,
|
||||
required this.quantity,
|
||||
this.notes = '',
|
||||
this.variant,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -20,17 +22,20 @@ class ProductQuantity {
|
||||
return other is ProductQuantity &&
|
||||
other.product == product &&
|
||||
other.quantity == quantity &&
|
||||
other.variant == variant &&
|
||||
other.notes == notes;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => product.hashCode ^ quantity.hashCode ^ notes.hashCode;
|
||||
int get hashCode =>
|
||||
product.hashCode ^ quantity.hashCode ^ variant.hashCode ^ notes.hashCode;
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'product': product.toMap(),
|
||||
'quantity': quantity,
|
||||
'notes': notes,
|
||||
'variant': variant?.toMap(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -43,6 +48,7 @@ class ProductQuantity {
|
||||
'quantity': quantity,
|
||||
'price': product.price,
|
||||
'notes': notes,
|
||||
'variant': variant?.toMap(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -55,6 +61,7 @@ class ProductQuantity {
|
||||
'quantity': quantity,
|
||||
'price': product.price,
|
||||
'notes': notes,
|
||||
'variant': variant?.toMap(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -63,6 +70,9 @@ class ProductQuantity {
|
||||
product: Product.fromMap(map['product']),
|
||||
quantity: map['quantity']?.toInt() ?? 0,
|
||||
notes: map['notes'] ?? '',
|
||||
variant: map['variant'] != null
|
||||
? ProductVariant.fromMap(map['variant'])
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -72,6 +82,9 @@ class ProductQuantity {
|
||||
product: Product.fromOrderMap(map),
|
||||
quantity: map['quantity']?.toInt() ?? 0,
|
||||
notes: map['notes'] ?? '',
|
||||
variant: map['variant'] != null
|
||||
? ProductVariant.fromMap(map['variant'])
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -89,6 +102,7 @@ class ProductQuantity {
|
||||
product: product ?? this.product,
|
||||
quantity: quantity ?? this.quantity,
|
||||
notes: notes ?? this.notes,
|
||||
variant: variant,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user