Files
Kifi/kifi-app/lib/features/inventory/domain/inventory_item.dart

92 lines
2.6 KiB
Dart

class InventoryItem {
final int? id;
final int? userId;
final int? productId;
final String? tagNumber;
final String? sku;
final String? huid;
final String? purity;
final double? grossWeight;
final double? netWeight;
final double? stoneWeight;
final double? diamondWeight;
final double? fineWeight;
final double? makingCharges;
final String? makingChargeType;
final double? purchaseCost;
final double? metalCost;
final double? stoneCost;
final double? certificationCost;
final double? tax;
final int? vendorId;
final int? branchId;
final String? purchaseRef;
final String? salesRef;
final double? saleRate;
final String? photoUrl;
final String? status;
final DateTime? createdAt;
InventoryItem({
this.id,
this.userId,
this.productId,
this.tagNumber,
this.sku,
this.huid,
this.purity,
this.grossWeight,
this.netWeight,
this.stoneWeight,
this.diamondWeight,
this.fineWeight,
this.makingCharges,
this.makingChargeType,
this.purchaseCost,
this.metalCost,
this.stoneCost,
this.certificationCost,
this.tax,
this.vendorId,
this.branchId,
this.purchaseRef,
this.salesRef,
this.saleRate,
this.photoUrl,
this.status,
this.createdAt,
});
factory InventoryItem.fromJson(Map<String, dynamic> json) {
return InventoryItem(
id: json['id'],
userId: json['userId'],
productId: json['productId'],
tagNumber: json['tagNumber'],
sku: json['sku'],
huid: json['huid'],
purity: json['purity'],
grossWeight: json['grossWeight']?.toDouble(),
netWeight: json['netWeight']?.toDouble(),
stoneWeight: json['stoneWeight']?.toDouble(),
diamondWeight: json['diamondWeight']?.toDouble(),
fineWeight: json['fineWeight']?.toDouble(),
makingCharges: json['makingCharges']?.toDouble(),
makingChargeType: json['makingChargeType'],
purchaseCost: json['purchaseCost']?.toDouble(),
metalCost: json['metalCost']?.toDouble(),
stoneCost: json['stoneCost']?.toDouble(),
certificationCost: json['certificationCost']?.toDouble(),
tax: json['tax']?.toDouble(),
vendorId: json['vendorId'],
branchId: json['branchId'],
purchaseRef: json['purchaseRef'],
salesRef: json['salesRef'] ?? json['sales_ref'],
saleRate: (json['saleRate'] ?? json['sale_rate'])?.toDouble(),
photoUrl: json['photoUrl'] ?? json['photo_url'],
status: json['status'],
createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt']) : null,
);
}
}