From 5a3e9c29774514e3bc730259dd5126e1dad1d81a Mon Sep 17 00:00:00 2001 From: Vaibhav Surve Date: Thu, 13 Nov 2025 12:26:39 +0530 Subject: [PATCH] corrected the payment proceed validation --- .../expense/reimbursement_bottom_sheet.dart | 31 +++++++++++++------ ...ent_request_rembursement_bottom_sheet.dart | 14 +++------ 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/lib/model/expense/reimbursement_bottom_sheet.dart b/lib/model/expense/reimbursement_bottom_sheet.dart index c2d235c..6ca4d81 100644 --- a/lib/model/expense/reimbursement_bottom_sheet.dart +++ b/lib/model/expense/reimbursement_bottom_sheet.dart @@ -197,22 +197,33 @@ class _ReimbursementBottomSheetState extends State { return; } - if (expenseTransactionDate != null && - selectedDate.isBefore(expenseTransactionDate)) { - showAppSnackbar( - title: "Invalid Date", - message: - "Reimbursement date cannot be before the transaction date (${DateFormat('yyyy-MM-dd').format(expenseTransactionDate)}).", - type: SnackbarType.warning, + if (expenseTransactionDate != null && selectedDate != null) { + final normalizedSelected = DateTime( + selectedDate.year, + selectedDate.month, + selectedDate.day, ); - return; + final normalizedTransaction = DateTime( + expenseTransactionDate.year, + expenseTransactionDate.month, + expenseTransactionDate.day, + ); + + if (normalizedSelected.isBefore(normalizedTransaction)) { + showAppSnackbar( + title: "Invalid Date", + message: + "Reimbursement date cannot be before the transaction date (${DateFormat('yyyy-MM-dd').format(expenseTransactionDate)}).", + type: SnackbarType.warning, + ); + return; + } } } final success = await widget.onSubmit( comment: commentCtrl.text.trim(), - reimburseTransactionId: txnCtrl.text - .trim(), + reimburseTransactionId: txnCtrl.text.trim(), reimburseDate: dateStr.value, reimburseById: controller.selectedReimbursedBy.value!.id, statusId: widget.statusId, diff --git a/lib/model/finance/payment_request_rembursement_bottom_sheet.dart b/lib/model/finance/payment_request_rembursement_bottom_sheet.dart index 0c39ca6..f8f6983 100644 --- a/lib/model/finance/payment_request_rembursement_bottom_sheet.dart +++ b/lib/model/finance/payment_request_rembursement_bottom_sheet.dart @@ -170,10 +170,11 @@ class _UpdatePaymentRequestWithReimbursementState dateStr.value.isEmpty || baseAmountCtrl.text.trim().isEmpty || taxAmountCtrl.text.trim().isEmpty || - commentCtrl.text.trim().isEmpty) { + commentCtrl.text.trim().isEmpty || + controller.selectedReimbursedBy.value == null) { showAppSnackbar( title: "Incomplete", - message: "Please fill all mandatory fields", + message: "Please fill all mandatory fields, including 'Paid By'", type: SnackbarType.warning, ); return; @@ -233,7 +234,6 @@ class _UpdatePaymentRequestWithReimbursementState decoration: _inputDecoration("Enter transaction ID"), ), MySpacing.height(16), - _requiredLabel("Transaction Date"), MySpacing.height(8), GestureDetector( @@ -266,8 +266,7 @@ class _UpdatePaymentRequestWithReimbursementState ), ), MySpacing.height(16), - - MyText.labelMedium("Paid By (Optional)"), + _requiredLabel("Paid By"), MySpacing.height(8), GestureDetector( onTap: _showEmployeeList, @@ -294,7 +293,6 @@ class _UpdatePaymentRequestWithReimbursementState ), ), MySpacing.height(16), - _requiredLabel("Base Amount"), MySpacing.height(8), TextField( @@ -303,7 +301,6 @@ class _UpdatePaymentRequestWithReimbursementState decoration: _inputDecoration("Enter Base Amount"), ), MySpacing.height(16), - _requiredLabel("GST Amount"), MySpacing.height(8), TextField( @@ -312,7 +309,6 @@ class _UpdatePaymentRequestWithReimbursementState decoration: _inputDecoration("Enter GST Amount"), ), MySpacing.height(16), - MyText.labelMedium("TDS Percent"), MySpacing.height(8), TextField( @@ -335,7 +331,6 @@ class _UpdatePaymentRequestWithReimbursementState color: Colors.grey.shade600, ), MySpacing.height(16), - Obx(() => Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -353,7 +348,6 @@ class _UpdatePaymentRequestWithReimbursementState ], )), MySpacing.height(20), - _requiredLabel("Comment"), MySpacing.height(8), TextField(