auto isBusiness based on customer selected

This commit is contained in:
2026-05-19 12:03:03 +02:00
parent 4e03d52a5d
commit 3f2f55d6c2
2 changed files with 12 additions and 6 deletions

View File

@@ -191,7 +191,6 @@ class OperationFormCubit extends Cubit<OperationFormState> {
// --- GESTIONE DEI CAMPI IN TEMPO REALE ---
void updateFields({
CustomerModel? customer,
String? reference,
String? note,
String? type,
@@ -224,8 +223,6 @@ class OperationFormCubit extends Cubit<OperationFormState> {
if (quantity != null && quantity > 0) newQuantity = quantity;
final updated = current.copyWith(
customer: customer ?? current.customer,
customerId: customer?.id ?? current.customerId,
reference: reference ?? current.reference,
note: note ?? current.note,
providerId: clearProvider ? null : (providerId ?? current.providerId),
@@ -254,6 +251,16 @@ class OperationFormCubit extends Cubit<OperationFormState> {
emit(state.copyWith(operation: updated));
}
void updateCustomer(CustomerModel customer) {
final bool isBusiness = customer.isBusiness;
final updatedOperation = state.operation.copyWith(
customer: customer,
customerId: customer.id,
isBusiness: isBusiness,
);
emit(state.copyWith(operation: updatedOperation));
}
// --- UTILS ---
void setTypeWithSmartDefault(String type) {