Files
Kifi/kifi-app/lib/features/business/domain/business_feature.dart

90 lines
3.0 KiB
Dart

class BusinessFeature {
final int? id;
final int? userId;
final bool inventoryManagement;
final bool salesManagement;
final bool purchaseManagement;
final bool multiLocation;
final String bomReductionStrategy;
final bool stockDeductionOnInvoice;
final String barcodeSource;
final bool enableEcommerceChannels;
final DateTime? createdAt;
BusinessFeature({
this.id,
this.userId,
this.inventoryManagement = false,
this.salesManagement = false,
this.purchaseManagement = false,
this.multiLocation = false,
this.bomReductionStrategy = 'COMPONENTS_ONLY',
this.stockDeductionOnInvoice = true,
this.barcodeSource = 'SKU',
this.enableEcommerceChannels = false,
this.createdAt,
});
factory BusinessFeature.fromJson(Map<String, dynamic> json) {
return BusinessFeature(
id: json['id'],
userId: json['userId'],
inventoryManagement: json['inventoryManagement'] ?? false,
salesManagement: json['salesManagement'] ?? false,
purchaseManagement: json['purchaseManagement'] ?? false,
multiLocation: json['multiLocation'] ?? false,
bomReductionStrategy: json['bomReductionStrategy'] ?? 'COMPONENTS_ONLY',
stockDeductionOnInvoice: json['stockDeductionOnInvoice'] ?? true,
barcodeSource: json['barcodeSource'] ?? 'SKU',
enableEcommerceChannels: json['enableEcommerceChannels'] ?? json['enable_ecommerce_channels'] ?? false,
createdAt: json['createdAt'] != null
? DateTime.parse(json['createdAt'])
: null,
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'userId': userId,
'inventoryManagement': inventoryManagement,
'salesManagement': salesManagement,
'purchaseManagement': purchaseManagement,
'multiLocation': multiLocation,
'bomReductionStrategy': bomReductionStrategy,
'stockDeductionOnInvoice': stockDeductionOnInvoice,
'barcodeSource': barcodeSource,
'enableEcommerceChannels': enableEcommerceChannels,
};
}
BusinessFeature copyWith({
int? id,
int? userId,
bool? inventoryManagement,
bool? salesManagement,
bool? purchaseManagement,
bool? multiLocation,
String? bomReductionStrategy,
bool? stockDeductionOnInvoice,
String? barcodeSource,
bool? enableEcommerceChannels,
}) {
return BusinessFeature(
id: id ?? this.id,
userId: userId ?? this.userId,
inventoryManagement: inventoryManagement ?? this.inventoryManagement,
salesManagement: salesManagement ?? this.salesManagement,
purchaseManagement: purchaseManagement ?? this.purchaseManagement,
multiLocation: multiLocation ?? this.multiLocation,
bomReductionStrategy: bomReductionStrategy ?? this.bomReductionStrategy,
stockDeductionOnInvoice:
stockDeductionOnInvoice ?? this.stockDeductionOnInvoice,
barcodeSource: barcodeSource ?? this.barcodeSource,
enableEcommerceChannels:
enableEcommerceChannels ?? this.enableEcommerceChannels,
createdAt: createdAt,
);
}
}