Product Add Done
This commit is contained in:
120
kifi-app/lib/features/inventory/domain/product.dart
Normal file
120
kifi-app/lib/features/inventory/domain/product.dart
Normal file
@@ -0,0 +1,120 @@
|
||||
class Product {
|
||||
final int? id;
|
||||
final int? userId;
|
||||
final int? categoryId;
|
||||
final int? uomId;
|
||||
final String name;
|
||||
final String? sku;
|
||||
final String? barcode;
|
||||
final String? description;
|
||||
final double? purchasePrice;
|
||||
final double? sellingPrice;
|
||||
final double? minStock;
|
||||
final double? reorderLevel;
|
||||
final double? gstRate;
|
||||
final String? dimensions;
|
||||
final double? weight;
|
||||
final String? color;
|
||||
final String? size;
|
||||
final String priceCalcRule;
|
||||
final bool autoCalculatePrice;
|
||||
final double? purityFactor;
|
||||
final double? makingCharges;
|
||||
final String? makingChargesType;
|
||||
final double? wastagePercentage;
|
||||
final bool trackInventory;
|
||||
final bool isActive;
|
||||
final List<int> imageIds;
|
||||
|
||||
Product({
|
||||
this.id,
|
||||
this.userId,
|
||||
this.categoryId,
|
||||
this.uomId,
|
||||
required this.name,
|
||||
this.sku,
|
||||
this.barcode,
|
||||
this.description,
|
||||
this.purchasePrice,
|
||||
this.sellingPrice,
|
||||
this.minStock,
|
||||
this.reorderLevel,
|
||||
this.gstRate,
|
||||
this.dimensions,
|
||||
this.weight,
|
||||
this.color,
|
||||
this.size,
|
||||
this.priceCalcRule = 'MANUAL',
|
||||
this.autoCalculatePrice = false,
|
||||
this.purityFactor = 1.0,
|
||||
this.makingCharges = 0.0,
|
||||
this.makingChargesType = 'FLAT',
|
||||
this.wastagePercentage = 0.0,
|
||||
this.trackInventory = true,
|
||||
this.isActive = true,
|
||||
this.imageIds = const [],
|
||||
});
|
||||
|
||||
factory Product.fromJson(Map<String, dynamic> json) {
|
||||
return Product(
|
||||
id: json['id'],
|
||||
userId: json['userId'],
|
||||
categoryId: json['categoryId'],
|
||||
uomId: json['uomId'],
|
||||
name: json['name'],
|
||||
sku: json['sku'],
|
||||
barcode: json['barcode'],
|
||||
description: json['description'],
|
||||
purchasePrice: (json['purchasePrice'] as num?)?.toDouble(),
|
||||
sellingPrice: (json['sellingPrice'] as num?)?.toDouble(),
|
||||
minStock: (json['minStock'] as num?)?.toDouble(),
|
||||
reorderLevel: (json['reorderLevel'] as num?)?.toDouble(),
|
||||
gstRate: (json['gstRate'] as num?)?.toDouble(),
|
||||
dimensions: json['dimensions'],
|
||||
weight: (json['weight'] as num?)?.toDouble(),
|
||||
color: json['color'],
|
||||
size: json['size'],
|
||||
priceCalcRule: json['priceCalcRule'] ?? 'MANUAL',
|
||||
autoCalculatePrice: json['autoCalculatePrice'] ?? false,
|
||||
purityFactor: (json['purityFactor'] as num?)?.toDouble() ?? 1.0,
|
||||
makingCharges: (json['makingCharges'] as num?)?.toDouble() ?? 0.0,
|
||||
makingChargesType: json['makingChargesType'] ?? 'FLAT',
|
||||
wastagePercentage: (json['wastagePercentage'] as num?)?.toDouble() ?? 0.0,
|
||||
trackInventory: json['trackInventory'] ?? true,
|
||||
isActive: json['isActive'] ?? true,
|
||||
imageIds: json['images'] != null
|
||||
? (json['images'] as List).map((i) => i['id'] as int).toList()
|
||||
: [],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'userId': userId,
|
||||
'categoryId': categoryId,
|
||||
'uomId': uomId,
|
||||
'name': name,
|
||||
'sku': sku,
|
||||
'barcode': barcode,
|
||||
'description': description,
|
||||
'purchasePrice': purchasePrice,
|
||||
'sellingPrice': sellingPrice,
|
||||
'minStock': minStock,
|
||||
'reorderLevel': reorderLevel,
|
||||
'gstRate': gstRate,
|
||||
'dimensions': dimensions,
|
||||
'weight': weight,
|
||||
'color': color,
|
||||
'size': size,
|
||||
'priceCalcRule': priceCalcRule,
|
||||
'autoCalculatePrice': autoCalculatePrice,
|
||||
'purityFactor': purityFactor,
|
||||
'makingCharges': makingCharges,
|
||||
'makingChargesType': makingChargesType,
|
||||
'wastagePercentage': wastagePercentage,
|
||||
'trackInventory': trackInventory,
|
||||
'isActive': isActive,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user