Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-05-03 12:05:47 +02:00
parent 4559db620d
commit 6bb65e8296
13 changed files with 832 additions and 815 deletions

View File

@@ -169,35 +169,49 @@ class OperationModel extends Equatable {
factory OperationModel.fromMap(Map<String, dynamic> map) {
return OperationModel(
id: map['id'],
id: map['id'] as String?,
createdAt: map['created_at'] != null
? DateTime.parse(map['created_at'])
: null,
type: map['type'] as String? ?? '',
subtype: map['sub_type'] as String?,
providerId: map['provider_id'] as String? ?? '',
providerDisplayName: "${map['provider']['name']}".myFormat(),
modelId: map['model_id'] as String? ?? '',
modelDisplayName: "${map['model']['name_with_brand'] ?? ''}".myFormat(),
description: map['description'] as String? ?? '',
// I campi relazionali nullabili restano rigorosamente null!
providerId: map['provider_id'] as String?,
// MAGIA ANTI-CRASH: Usiamo ?['chiave'] per non far esplodere i join vuoti
providerDisplayName: (map['provider']?['name'] as String?)?.myFormat(),
modelId: map['model_id'] as String?,
modelDisplayName: (map['model']?['name_with_brand'] as String?)
?.myFormat(),
description: map['description'] as String?,
expirationDate: map['expiration_date'] != null
? DateTime.parse(map['expiration_date'])
: null,
note: map['note'] as String? ?? '',
showInDashboard: map['show_in_dashboard'] as bool,
batchUuid: map['batch_uuid'] as String,
showInDashboard: map['show_in_dashboard'] as bool? ?? true,
batchUuid: map['batch_uuid'] as String? ?? '',
companyId: map['company_id'] as String,
storeId: map['store_id'] as String? ?? '',
storeDisplayName: "${map['store']['name']}".myFormat(),
storeId:
map['store_id'] as String? ??
'', // Questo è non-nullable nella tua classe
storeDisplayName: (map['store']?['name'] as String?)?.myFormat(),
quantity: map['quantity'] is int
? map['quantity']
: int.tryParse(map['quantity']?.toString() ?? '0') ?? 0,
staffId: map['staff_id'] as String? ?? '',
staffDisplayName: "${map['staff_member']['name'] ?? ''}".myFormat(),
lastCampaignId: map['last_campaign_id'] as String? ?? '',
status: OperationStatus.fromString(map['status']),
customerId: map['customer_id'] as String? ?? '',
customerDisplayName: "${map['customer']['name'] ?? ''}".myFormat(),
: int.tryParse(map['quantity']?.toString() ?? '1') ?? 1,
staffId: map['staff_id'] as String?,
staffDisplayName: (map['staff_member']?['name'] as String?)?.myFormat(),
lastCampaignId: map['last_campaign_id'] as String?,
status: OperationStatus.fromString(map['status'] ?? 'draft'),
customerId: map['customer_id'] as String?,
customerDisplayName: (map['customer']?['name'] as String?)?.myFormat(),
attachments:
(map['attachment'] as List?)
?.map((x) => AttachmentModel.fromMap(x))