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

47 lines
1.4 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(
3 years ago
type: Lookup.fromJson(parsedJson["type"]),
cylinderSize: Lookup.fromJson(parsedJson["size"]),
3 years ago
requestedQuantity: parsedJson["requsted_qty"] == null
3 years ago
? 0
: int.tryParse(parsedJson["requsted_qty"].toString()) ?? 0,
3 years ago
deliveredQuantity: parsedJson["deliverd_qty"] == null
3 years ago
? 0
: int.tryParse(parsedJson["deliverd_qty"].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
);
}
}