refactor shipping attachments and changed shipment to shipping for coherence
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flux/features/attachments/models/attachment_model.dart';
|
||||
|
||||
class ShipmentDocumentModel extends Equatable {
|
||||
class ShippingDocumentModel extends Equatable {
|
||||
final String? id;
|
||||
final String companyId;
|
||||
final List<String> ticketIds;
|
||||
@@ -12,8 +13,9 @@ class ShipmentDocumentModel extends Equatable {
|
||||
final double? weight;
|
||||
final String shippingReason;
|
||||
final String? notes;
|
||||
final List<AttachmentModel> attachments;
|
||||
|
||||
const ShipmentDocumentModel({
|
||||
const ShippingDocumentModel({
|
||||
this.id,
|
||||
required this.companyId,
|
||||
required this.ticketIds,
|
||||
@@ -25,9 +27,10 @@ class ShipmentDocumentModel extends Equatable {
|
||||
this.weight,
|
||||
this.shippingReason = 'Riparazione esterna',
|
||||
this.notes,
|
||||
this.attachments = const [],
|
||||
});
|
||||
|
||||
ShipmentDocumentModel copyWith({
|
||||
ShippingDocumentModel copyWith({
|
||||
String? id,
|
||||
String? companyId,
|
||||
List<String>? ticketIds,
|
||||
@@ -39,8 +42,9 @@ class ShipmentDocumentModel extends Equatable {
|
||||
double? weight,
|
||||
String? shippingReason,
|
||||
String? notes,
|
||||
List<AttachmentModel>? attachments,
|
||||
}) {
|
||||
return ShipmentDocumentModel(
|
||||
return ShippingDocumentModel(
|
||||
id: id ?? this.id,
|
||||
companyId: companyId ?? this.companyId,
|
||||
ticketIds: ticketIds ?? this.ticketIds,
|
||||
@@ -53,11 +57,12 @@ class ShipmentDocumentModel extends Equatable {
|
||||
weight: weight ?? this.weight,
|
||||
shippingReason: shippingReason ?? this.shippingReason,
|
||||
notes: notes ?? this.notes,
|
||||
attachments: attachments ?? this.attachments,
|
||||
);
|
||||
}
|
||||
|
||||
factory ShipmentDocumentModel.fromMap(Map<String, dynamic> map) {
|
||||
return ShipmentDocumentModel(
|
||||
factory ShippingDocumentModel.fromMap(Map<String, dynamic> map) {
|
||||
return ShippingDocumentModel(
|
||||
id: map['id'],
|
||||
companyId: map['company_id'],
|
||||
ticketIds: List<String>.from(map['ticket_ids']),
|
||||
@@ -69,6 +74,11 @@ class ShipmentDocumentModel extends Equatable {
|
||||
weight: map['weight'] != null ? (map['weight'] as num).toDouble() : null,
|
||||
shippingReason: map['shipping_reason'] ?? 'Riparazione esterna',
|
||||
notes: map['notes'],
|
||||
attachments:
|
||||
(map['attachments'] as List<dynamic>?)
|
||||
?.map((e) => AttachmentModel.fromMap(e))
|
||||
.toList() ??
|
||||
const [],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -89,5 +99,17 @@ class ShipmentDocumentModel extends Equatable {
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [id, docNumber, ticketIds];
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
docNumber,
|
||||
ticketIds,
|
||||
providerId,
|
||||
destinationLocationId,
|
||||
docDate,
|
||||
packageCount,
|
||||
weight,
|
||||
shippingReason,
|
||||
notes,
|
||||
attachments,
|
||||
];
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flux/core/utils/extensions.dart';
|
||||
import 'package:flux/features/customers/models/customer_model.dart';
|
||||
import 'package:flux/features/tickets/models/shipment_document_model.dart';
|
||||
import 'package:flux/features/tickets/models/shipping_document_model.dart';
|
||||
|
||||
/// Enum per il tipo di ticket
|
||||
enum TicketType {
|
||||
@@ -121,8 +121,7 @@ class TicketModel extends Equatable {
|
||||
final String? assignedToId;
|
||||
final String? assignedToName;
|
||||
final String? includedAccessories;
|
||||
final ShipmentDocumentModel?
|
||||
shippingDocument; // Per tenere in memoria i dati del DDT associato al ticket
|
||||
final ShippingDocumentModel? shippingDocument;
|
||||
|
||||
const TicketModel({
|
||||
this.id,
|
||||
@@ -215,7 +214,7 @@ class TicketModel extends Equatable {
|
||||
String? assignedToId,
|
||||
String? assignedToName,
|
||||
String? includedAccessories,
|
||||
ShipmentDocumentModel? shippingDocument,
|
||||
ShippingDocumentModel? shippingDocument,
|
||||
}) {
|
||||
return TicketModel(
|
||||
id: id ?? this.id,
|
||||
@@ -312,7 +311,7 @@ class TicketModel extends Equatable {
|
||||
assignedToName: (map['assigned_to']?['name'] as String?)?.myFormat(),
|
||||
includedAccessories: map['included_accessories'] as String?,
|
||||
shippingDocument: map['shipping_document'] != null
|
||||
? ShipmentDocumentModel.fromMap(
|
||||
? ShippingDocumentModel.fromMap(
|
||||
map['shipping_document'] as Map<String, dynamic>,
|
||||
)
|
||||
: null,
|
||||
|
||||
Reference in New Issue
Block a user