import 'package:test_sa/models/lookup.dart';

class GasRefillDetails{
  Lookup type;
  Lookup cylinderSize;
  Lookup cylinderType;
  double requestedQuantity;
  double deliveredQuantity;

  GasRefillDetails({
    this.type,
    this.cylinderSize,
    this.cylinderType,
    this.requestedQuantity,
    this.deliveredQuantity,
  });

  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"]),
      cylinderType: Lookup.fromJson(parsedJson["cylinderType"]),
      requestedQuantity: parsedJson["requestedQty"],
      deliveredQuantity: parsedJson["deliverdQty"],
    );
  }

  factory GasRefillDetails.fromDetails(GasRefillDetails details){
    return GasRefillDetails(
      type: Lookup.fromStatus(details.type),
      cylinderSize:Lookup.fromStatus(details.cylinderSize),
      cylinderType:Lookup.fromStatus(details.cylinderType),
      requestedQuantity: details.requestedQuantity,
      deliveredQuantity: details.deliveredQuantity,
    );
  }
}

