2026-05-15 10:12:05 +02:00
|
|
|
import 'package:equatable/equatable.dart';
|
2026-05-18 12:00:07 +02:00
|
|
|
import 'package:flux/features/attachments/models/attachment_model.dart';
|
2026-05-15 10:12:05 +02:00
|
|
|
|
2026-05-18 12:00:07 +02:00
|
|
|
class ShippingDocumentModel extends Equatable {
|
2026-05-15 10:12:05 +02:00
|
|
|
final String? id;
|
|
|
|
|
final String companyId;
|
2026-05-15 19:18:03 +02:00
|
|
|
final List<String> ticketIds;
|
2026-05-15 10:12:05 +02:00
|
|
|
final String providerId;
|
|
|
|
|
final String destinationLocationId;
|
|
|
|
|
final String docNumber;
|
|
|
|
|
final DateTime docDate;
|
|
|
|
|
final int packageCount;
|
|
|
|
|
final double? weight;
|
|
|
|
|
final String shippingReason;
|
|
|
|
|
final String? notes;
|
2026-05-18 12:00:07 +02:00
|
|
|
final List<AttachmentModel> attachments;
|
2026-05-15 10:12:05 +02:00
|
|
|
|
2026-05-18 12:00:07 +02:00
|
|
|
const ShippingDocumentModel({
|
2026-05-15 10:12:05 +02:00
|
|
|
this.id,
|
|
|
|
|
required this.companyId,
|
2026-05-15 19:18:03 +02:00
|
|
|
required this.ticketIds,
|
2026-05-15 10:12:05 +02:00
|
|
|
required this.providerId,
|
|
|
|
|
required this.destinationLocationId,
|
|
|
|
|
required this.docNumber,
|
|
|
|
|
required this.docDate,
|
|
|
|
|
this.packageCount = 1,
|
|
|
|
|
this.weight,
|
|
|
|
|
this.shippingReason = 'Riparazione esterna',
|
|
|
|
|
this.notes,
|
2026-05-18 12:00:07 +02:00
|
|
|
this.attachments = const [],
|
2026-05-15 10:12:05 +02:00
|
|
|
});
|
|
|
|
|
|
2026-05-18 12:00:07 +02:00
|
|
|
ShippingDocumentModel copyWith({
|
2026-05-15 19:18:03 +02:00
|
|
|
String? id,
|
|
|
|
|
String? companyId,
|
|
|
|
|
List<String>? ticketIds,
|
|
|
|
|
String? providerId,
|
|
|
|
|
String? destinationLocationId,
|
|
|
|
|
String? docNumber,
|
|
|
|
|
DateTime? docDate,
|
|
|
|
|
int? packageCount,
|
|
|
|
|
double? weight,
|
|
|
|
|
String? shippingReason,
|
|
|
|
|
String? notes,
|
2026-05-18 12:00:07 +02:00
|
|
|
List<AttachmentModel>? attachments,
|
2026-05-15 19:18:03 +02:00
|
|
|
}) {
|
2026-05-18 12:00:07 +02:00
|
|
|
return ShippingDocumentModel(
|
2026-05-15 19:18:03 +02:00
|
|
|
id: id ?? this.id,
|
|
|
|
|
companyId: companyId ?? this.companyId,
|
|
|
|
|
ticketIds: ticketIds ?? this.ticketIds,
|
|
|
|
|
providerId: providerId ?? this.providerId,
|
|
|
|
|
destinationLocationId:
|
|
|
|
|
destinationLocationId ?? this.destinationLocationId,
|
|
|
|
|
docNumber: docNumber ?? this.docNumber,
|
|
|
|
|
docDate: docDate ?? this.docDate,
|
|
|
|
|
packageCount: packageCount ?? this.packageCount,
|
|
|
|
|
weight: weight ?? this.weight,
|
|
|
|
|
shippingReason: shippingReason ?? this.shippingReason,
|
|
|
|
|
notes: notes ?? this.notes,
|
2026-05-18 12:00:07 +02:00
|
|
|
attachments: attachments ?? this.attachments,
|
2026-05-15 19:18:03 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-18 12:00:07 +02:00
|
|
|
factory ShippingDocumentModel.fromMap(Map<String, dynamic> map) {
|
|
|
|
|
return ShippingDocumentModel(
|
2026-05-15 10:12:05 +02:00
|
|
|
id: map['id'],
|
|
|
|
|
companyId: map['company_id'],
|
2026-05-15 19:18:03 +02:00
|
|
|
ticketIds: List<String>.from(map['ticket_ids']),
|
2026-05-15 10:12:05 +02:00
|
|
|
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'],
|
2026-05-18 12:00:07 +02:00
|
|
|
attachments:
|
|
|
|
|
(map['attachments'] as List<dynamic>?)
|
|
|
|
|
?.map((e) => AttachmentModel.fromMap(e))
|
|
|
|
|
.toList() ??
|
|
|
|
|
const [],
|
2026-05-15 10:12:05 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
|
return {
|
|
|
|
|
if (id != null) 'id': id,
|
|
|
|
|
'company_id': companyId,
|
2026-05-15 19:18:03 +02:00
|
|
|
'ticket_ids': ticketIds,
|
2026-05-15 10:12:05 +02:00
|
|
|
'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
|
2026-05-18 12:00:07 +02:00
|
|
|
List<Object?> get props => [
|
|
|
|
|
id,
|
|
|
|
|
docNumber,
|
|
|
|
|
ticketIds,
|
|
|
|
|
providerId,
|
|
|
|
|
destinationLocationId,
|
|
|
|
|
docDate,
|
|
|
|
|
packageCount,
|
|
|
|
|
weight,
|
|
|
|
|
shippingReason,
|
|
|
|
|
notes,
|
|
|
|
|
attachments,
|
|
|
|
|
];
|
2026-05-15 10:12:05 +02:00
|
|
|
}
|