|
|
|
import 'm_asset_status_model.dart';
|
|
|
|
import 'warehouse_mode.dart';
|
|
|
|
|
|
|
|
class AssetStatusModel {
|
|
|
|
int? id;
|
|
|
|
String? mobile_id;
|
|
|
|
int? peti_id;
|
|
|
|
int? customer_id;
|
|
|
|
int? warehouse_id;
|
|
|
|
DateTime? exit_at;
|
|
|
|
String? exit_pic;
|
|
|
|
// int? exit_warehouse;
|
|
|
|
DateTime? enter_at;
|
|
|
|
String? enter_pic;
|
|
|
|
int? enter_warehouse;
|
|
|
|
DateTime? est_pengembalian;
|
|
|
|
int? kondisi_peti_id;
|
|
|
|
// int? status;
|
|
|
|
String? created_by;
|
|
|
|
String? updated_by;
|
|
|
|
DateTime? created_at;
|
|
|
|
DateTime? updated_at;
|
|
|
|
DateTime? deleted_at;
|
|
|
|
// PetiAssetModel? peti;
|
|
|
|
// WarehouseModel? warehouse;
|
|
|
|
// WarehouseEnterModel? warehouse_enter;
|
|
|
|
|
|
|
|
AssetStatusModel({
|
|
|
|
required this.id,
|
|
|
|
this.mobile_id,
|
|
|
|
this.peti_id,
|
|
|
|
this.customer_id,
|
|
|
|
this.warehouse_id,
|
|
|
|
this.exit_at,
|
|
|
|
this.exit_pic,
|
|
|
|
// this.exit_warehouse,
|
|
|
|
this.enter_at,
|
|
|
|
this.enter_pic,
|
|
|
|
this.enter_warehouse,
|
|
|
|
this.est_pengembalian,
|
|
|
|
this.kondisi_peti_id,
|
|
|
|
// this.status,
|
|
|
|
this.created_by,
|
|
|
|
this.updated_by,
|
|
|
|
this.created_at,
|
|
|
|
this.updated_at,
|
|
|
|
this.deleted_at,
|
|
|
|
// this.peti,
|
|
|
|
// this.warehouse,
|
|
|
|
// this.warehouse_enter,
|
|
|
|
});
|
|
|
|
|
|
|
|
factory AssetStatusModel.fromJson(Map<String, dynamic> json) {
|
|
|
|
return AssetStatusModel(
|
|
|
|
id: json['id'] != null ? int.parse(json['id'].toString()) : 0,
|
|
|
|
mobile_id: json['mobile_id'].toString(),
|
|
|
|
peti_id:
|
|
|
|
json['peti_id'] != null ? int.parse(json['peti_id'].toString()) : 0,
|
|
|
|
customer_id: json['customer_id'] != null
|
|
|
|
? int.parse(json['customer_id'].toString())
|
|
|
|
: 0,
|
|
|
|
warehouse_id: json['warehouse_id'] != null
|
|
|
|
? int.parse(json['warehouse_id'].toString())
|
|
|
|
: 0,
|
|
|
|
exit_at: parseDateTime(json['exit_at']),
|
|
|
|
exit_pic: json['exit_pic'],
|
|
|
|
// exit_warehouse: json['exit_warehouse'] != null
|
|
|
|
// ? int.parse(json['exit_warehouse'].toString())
|
|
|
|
// : 0,
|
|
|
|
enter_at: parseDateTime(json['enter_at']),
|
|
|
|
enter_pic: json['enter_pic'],
|
|
|
|
enter_warehouse: json['enter_warehouse'] != null
|
|
|
|
? int.parse(json['enter_warehouse'].toString())
|
|
|
|
: 0,
|
|
|
|
est_pengembalian: parseDateTime(json['est_pengembalian']),
|
|
|
|
kondisi_peti_id: json['kondisi_peti_id'] != null
|
|
|
|
? int.parse(json['kondisi_peti_id'].toString())
|
|
|
|
: 0,
|
|
|
|
created_by: json['created_by'] ?? 'null',
|
|
|
|
updated_by: json['updated_by'] ?? 'null',
|
|
|
|
created_at: parseDateTime(json['created_at']),
|
|
|
|
updated_at: parseDateTime(json['updated_at']),
|
|
|
|
deleted_at: parseDateTime(json['deleted_at']),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
|
|
'id': id,
|
|
|
|
'mobile_id': mobile_id.toString(),
|
|
|
|
'peti_id': peti_id,
|
|
|
|
'customer_id': customer_id,
|
|
|
|
'warehouse_id': warehouse_id,
|
|
|
|
'exit_at': exit_at?.toIso8601String(),
|
|
|
|
'exit_pic': exit_pic.toString(),
|
|
|
|
// 'exit_warehouse': exit_warehouse,
|
|
|
|
'enter_at': enter_at?.toIso8601String(),
|
|
|
|
'enter_pic': enter_pic,
|
|
|
|
'enter_warehouse': enter_warehouse?.toString(),
|
|
|
|
'est_pengembalian': est_pengembalian?.toIso8601String(),
|
|
|
|
'kondisi_peti_id': kondisi_peti_id,
|
|
|
|
// 'status': status.toString(),
|
|
|
|
'created_by': created_by,
|
|
|
|
'updated_by': updated_by,
|
|
|
|
'created_at': created_at?.toIso8601String(),
|
|
|
|
'updated_at': updated_at?.toIso8601String(),
|
|
|
|
'deleted_at': deleted_at?.toIso8601String(),
|
|
|
|
// 'peti': peti!.toJson(),
|
|
|
|
// 'warehouse': warehouse!.toJson(),
|
|
|
|
// 'warehouse_enter': warehouse_enter!.toJson(),
|
|
|
|
};
|
|
|
|
|
|
|
|
static DateTime? parseDateTime(String? dateTimeString) {
|
|
|
|
if (dateTimeString != null && dateTimeString.isNotEmpty) {
|
|
|
|
try {
|
|
|
|
return DateTime.parse(dateTimeString);
|
|
|
|
} catch (e) {
|
|
|
|
print('Error parsing DateTime: $e');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|