Product Add Done

This commit is contained in:
2026-08-16 22:51:34 +05:30
parent 17c0526ed6
commit ba9a9fd8a4
60 changed files with 5098 additions and 22 deletions

View 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,
};
}
}