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.
44 lines
1.3 KiB
Dart
44 lines
1.3 KiB
Dart
import '../lookup.dart';
|
|
|
|
class GasRefillDetails {
|
|
Lookup? type;
|
|
Lookup? cylinderSize;
|
|
int? requestedQuantity;
|
|
int? deliveredQuantity;
|
|
|
|
GasRefillDetails({
|
|
this.type,
|
|
this.cylinderSize,
|
|
this.requestedQuantity,
|
|
this.deliveredQuantity,
|
|
required model,
|
|
});
|
|
|
|
bool validate() {
|
|
//if(cylinderSize == null) return false;
|
|
if (type == null) return false;
|
|
if (requestedQuantity == null) return false;
|
|
return true;
|
|
}
|
|
|
|
factory GasRefillDetails.fromJson(Map<String, dynamic> parsedJson) {
|
|
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,
|
|
);
|
|
}
|
|
|
|
factory GasRefillDetails.fromDetails(GasRefillDetails details) {
|
|
return GasRefillDetails(
|
|
type: details.type != null ? Lookup.fromStatus(details.type!) : null,
|
|
cylinderSize: details.cylinderSize != null ? Lookup.fromStatus(details.cylinderSize!) : null,
|
|
requestedQuantity: details.requestedQuantity,
|
|
deliveredQuantity: details.deliveredQuantity,
|
|
model: null,
|
|
);
|
|
}
|
|
}
|