diff --git a/lib/model/expense/add_expense_bottom_sheet.dart b/lib/model/expense/add_expense_bottom_sheet.dart index 2c3e43b..03f7c4f 100644 --- a/lib/model/expense/add_expense_bottom_sheet.dart +++ b/lib/model/expense/add_expense_bottom_sheet.dart @@ -118,7 +118,61 @@ class _AddExpenseBottomSheetState extends State<_AddExpenseBottomSheet> { onCancel: Get.back, onSubmit: () { if (_formKey.currentState!.validate()) { + // Additional dropdown validation + if (controller.selectedProject.value.isEmpty) { + showAppSnackbar( + title: "Error", + message: "Please select a project", + type: SnackbarType.error, + ); + return; + } + + if (controller.selectedExpenseType.value == null) { + showAppSnackbar( + title: "Error", + message: "Please select an expense type", + type: SnackbarType.error, + ); + return; + } + + if (controller.selectedPaymentMode.value == null) { + showAppSnackbar( + title: "Error", + message: "Please select a payment mode", + type: SnackbarType.error, + ); + return; + } + + if (controller.selectedPaidBy.value == null) { + showAppSnackbar( + title: "Error", + message: "Please select a person who paid", + type: SnackbarType.error, + ); + return; + } + + if (controller.attachments.isEmpty && + controller.existingAttachments.isEmpty) { + showAppSnackbar( + title: "Error", + message: "Please attach at least one document", + type: SnackbarType.error, + ); + return; + } + + // Validation passed, submit controller.submitOrUpdateExpense(); + } else { + showAppSnackbar( + title: "Error", + message: "Please fill all required fields correctly", + type: SnackbarType.error, + ); } }, child: SingleChildScrollView( @@ -186,12 +240,6 @@ class _AddExpenseBottomSheetState extends State<_AddExpenseBottomSheet> { _CustomTextField( controller: controller.gstController, hint: "Enter GST No.", - validator: (value) { - if (value != null && value.isNotEmpty) { - return Validators.gstValidator(value); - } - return null; - }, ), MySpacing.height(16), @@ -284,7 +332,7 @@ class _AddExpenseBottomSheetState extends State<_AddExpenseBottomSheet> { if (value != null && value.isNotEmpty) { return Validators.transactionIdValidator(value); } - return null; + return null; }, ),