This commit is contained in:
2026-06-03 12:08:59 +02:00
parent 8ad2b7cf7e
commit a7fd37a894
9 changed files with 589 additions and 166 deletions

View File

@@ -98,17 +98,23 @@ class OperationFormCubit extends Cubit<OperationFormState> {
emit(
state.copyWith(
status: OperationFormStatus.ready, // Torna ready per il nuovo form
status: OperationFormStatus.ready,
operation: OperationModel(
companyId: current.companyId,
storeId: current.storeId,
storeDisplayName: current.storeDisplayName,
batchUuid: current.batchUuid, // MANTIENE IL COLLEGAMENTO
customerId: current.customerId, // MANTIENE IL CLIENTE
// 🥷 REINSERIAMO LO STAFF (Il "colpevole" era qui)
staffId: current.staffId,
staffDisplayName: current.staffDisplayName,
batchUuid: current.batchUuid,
customerId: current.customerId,
customer: current.customer,
reference: current.reference,
status: OperationStatus.draft,
createdAt: DateTime.now(),
// Mantieni isBusiness se vuoi che rimanga coerente col cliente
isBusiness: current.isBusiness,
),
),
);
@@ -213,7 +219,7 @@ class OperationFormCubit extends Cubit<OperationFormState> {
String? type,
String? providerId,
String? providerDisplayName,
String? subtype,
String? subType,
String? description,
DateTime? expirationDate,
int? quantity,
@@ -226,7 +232,7 @@ class OperationFormCubit extends Cubit<OperationFormState> {
bool clearProvider = false,
bool clearType = false,
bool clearSubtype = false,
bool clearSubType = false,
bool clearDescription = false,
bool clearExpiration = false,
bool clearQuantity = false,
@@ -251,7 +257,7 @@ class OperationFormCubit extends Cubit<OperationFormState> {
description: clearDescription
? null
: (description ?? current.description),
subtype: clearSubtype ? null : (subtype ?? current.subtype),
subType: clearSubType ? null : (subType ?? current.subType),
expirationDate: clearExpiration
? null
: (expirationDate ?? current.expirationDate),
@@ -287,7 +293,7 @@ class OperationFormCubit extends Cubit<OperationFormState> {
}) {
// 1. Aggiorniamo il tipo nel modello in canna
// (Presumo tu abbia un metodo copyWith o simile)
final updatedOp = state.operation.copyWith(type: newType, subtype: '');
final updatedOp = state.operation.copyWith(type: newType, subType: '');
// 2. Prepariamoci ad auto-selezionare il provider
String? newProviderId = updatedOp.providerId;
@@ -389,7 +395,7 @@ class OperationFormCubit extends Cubit<OperationFormState> {
state.copyWith(
operation: currentOp.copyWith(
type: newType,
subtype:
subType:
'', // Resettiamo il sottotipo per evitare incongruenze (es. passo da Luce a DAZN)
expirationDate:
defaultDate, // Impostiamo la scadenza di default se calcolata