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

45 lines
1.3 KiB
Dart

import 'package:test_sa/models/lookup.dart';
3 years ago
class GasRefillDetails {
Lookup type;
Lookup cylinderSize;
3 years ago
Lookup cylinderType;
double requestedQuantity;
double deliveredQuantity;
3 years ago
GasRefillDetails({
this.type,
this.cylinderSize,
3 years ago
this.cylinderType,
3 years ago
this.requestedQuantity,
this.deliveredQuantity,
});
bool validate() {
3 years ago
//if(cylinderSize == null) return false;
if (type == null) return false;
if (requestedQuantity == null) return false;
3 years ago
return true;
}
factory GasRefillDetails.fromJson(Map<String, dynamic> parsedJson) {
3 years ago
return GasRefillDetails(
3 years ago
type: Lookup.fromJson(parsedJson["gasType"]),
cylinderSize: Lookup.fromJson(parsedJson["cylinderSize"]),
cylinderType: Lookup.fromJson(parsedJson["cylinderType"]),
requestedQuantity: parsedJson["requestedQty"],
deliveredQuantity: parsedJson["deliverdQty"],
3 years ago
);
}
factory GasRefillDetails.fromDetails(GasRefillDetails details) {
3 years ago
return GasRefillDetails(
type: Lookup.fromStatus(details.type),
cylinderSize: Lookup.fromStatus(details.cylinderSize),
cylinderType: Lookup.fromStatus(details.cylinderType),
3 years ago
requestedQuantity: details.requestedQuantity,
deliveredQuantity: details.deliveredQuantity,
);
}
}