65 lines
1.8 KiB
Dart
65 lines
1.8 KiB
Dart
|
|
import 'package:equatable/equatable.dart';
|
||
|
|
|
||
|
|
class ShipmentDocumentModel extends Equatable {
|
||
|
|
final String? id;
|
||
|
|
final String companyId;
|
||
|
|
final String ticketId;
|
||
|
|
final String providerId;
|
||
|
|
final String destinationLocationId;
|
||
|
|
final String docNumber;
|
||
|
|
final DateTime docDate;
|
||
|
|
final int packageCount;
|
||
|
|
final double? weight;
|
||
|
|
final String shippingReason;
|
||
|
|
final String? notes;
|
||
|
|
|
||
|
|
const ShipmentDocumentModel({
|
||
|
|
this.id,
|
||
|
|
required this.companyId,
|
||
|
|
required this.ticketId,
|
||
|
|
required this.providerId,
|
||
|
|
required this.destinationLocationId,
|
||
|
|
required this.docNumber,
|
||
|
|
required this.docDate,
|
||
|
|
this.packageCount = 1,
|
||
|
|
this.weight,
|
||
|
|
this.shippingReason = 'Riparazione esterna',
|
||
|
|
this.notes,
|
||
|
|
});
|
||
|
|
|
||
|
|
factory ShipmentDocumentModel.fromMap(Map<String, dynamic> map) {
|
||
|
|
return ShipmentDocumentModel(
|
||
|
|
id: map['id'],
|
||
|
|
companyId: map['company_id'],
|
||
|
|
ticketId: map['ticket_id'],
|
||
|
|
providerId: map['provider_id'],
|
||
|
|
destinationLocationId: map['destination_location_id'],
|
||
|
|
docNumber: map['doc_number'],
|
||
|
|
docDate: DateTime.parse(map['doc_date']),
|
||
|
|
packageCount: map['package_count'] ?? 1,
|
||
|
|
weight: map['weight'] != null ? (map['weight'] as num).toDouble() : null,
|
||
|
|
shippingReason: map['shipping_reason'] ?? 'Riparazione esterna',
|
||
|
|
notes: map['notes'],
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
Map<String, dynamic> toMap() {
|
||
|
|
return {
|
||
|
|
if (id != null) 'id': id,
|
||
|
|
'company_id': companyId,
|
||
|
|
'ticket_id': ticketId,
|
||
|
|
'provider_id': providerId,
|
||
|
|
'destination_location_id': destinationLocationId,
|
||
|
|
'doc_number': docNumber,
|
||
|
|
'doc_date': docDate.toIso8601String(),
|
||
|
|
'package_count': packageCount,
|
||
|
|
'weight': weight,
|
||
|
|
'shipping_reason': shippingReason,
|
||
|
|
'notes': notes,
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
List<Object?> get props => [id, docNumber, ticketId];
|
||
|
|
}
|