You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/models/gas_refill/gas_refill_details.dart

44 lines
1.3 KiB
Dart

3 years ago
import '../lookup.dart';
3 years ago
3 years ago
class GasRefillDetails {
Lookup? type;
Lookup? cylinderSize;
int? requestedQuantity;
int? deliveredQuantity;
3 years ago
GasRefillDetails({
this.type,
this.cylinderSize,
this.requestedQuantity,
this.deliveredQuantity,
required model,
3 years ago
});
3 years ago
bool validate() {
3 years ago
//if(cylinderSize == null) return false;
3 years ago
if (type == null) return false;
if (requestedQuantity == null) return false;
3 years ago
return true;
}
3 years ago
factory GasRefillDetails.fromJson(Map<String, dynamic> parsedJson) {
3 years ago
return GasRefillDetails(
type: Lookup.fromJson(parsedJson["gasType"]),
cylinderSize: Lookup.fromJson(parsedJson["cylinderSize"]),
requestedQuantity: parsedJson["requestedQty"] == null ? 0 : int.tryParse(parsedJson["requestedQty"].toString()) ?? 0,
deliveredQuantity: parsedJson["deliverdQty"] == null ? 0 : int.tryParse(parsedJson["deliverdQty"].toString()) ?? 0,
model: null,
3 years ago
);
}
3 years ago
factory GasRefillDetails.fromDetails(GasRefillDetails details) {
3 years ago
return GasRefillDetails(
3 years ago
type: details.type != null ? Lookup.fromStatus(details.type!) : null,
cylinderSize: details.cylinderSize != null ? Lookup.fromStatus(details.cylinderSize!) : null,
3 years ago
requestedQuantity: details.requestedQuantity,
deliveredQuantity: details.deliveredQuantity,
model: null,
3 years ago
);
}
}