corrected the payment proceed validation

This commit is contained in:
Vaibhav Surve 2025-11-13 12:26:39 +05:30 committed by Manish
parent 456df30c8e
commit 02c10d8115
2 changed files with 25 additions and 20 deletions

View File

@ -197,22 +197,33 @@ class _ReimbursementBottomSheetState extends State<ReimbursementBottomSheet> {
return; return;
} }
if (expenseTransactionDate != null && if (expenseTransactionDate != null && selectedDate != null) {
selectedDate.isBefore(expenseTransactionDate)) { final normalizedSelected = DateTime(
showAppSnackbar( selectedDate.year,
title: "Invalid Date", selectedDate.month,
message: selectedDate.day,
"Reimbursement date cannot be before the transaction date (${DateFormat('yyyy-MM-dd').format(expenseTransactionDate)}).",
type: SnackbarType.warning,
); );
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( final success = await widget.onSubmit(
comment: commentCtrl.text.trim(), comment: commentCtrl.text.trim(),
reimburseTransactionId: txnCtrl.text reimburseTransactionId: txnCtrl.text.trim(),
.trim(),
reimburseDate: dateStr.value, reimburseDate: dateStr.value,
reimburseById: controller.selectedReimbursedBy.value!.id, reimburseById: controller.selectedReimbursedBy.value!.id,
statusId: widget.statusId, statusId: widget.statusId,

View File

@ -170,10 +170,11 @@ class _UpdatePaymentRequestWithReimbursementState
dateStr.value.isEmpty || dateStr.value.isEmpty ||
baseAmountCtrl.text.trim().isEmpty || baseAmountCtrl.text.trim().isEmpty ||
taxAmountCtrl.text.trim().isEmpty || taxAmountCtrl.text.trim().isEmpty ||
commentCtrl.text.trim().isEmpty) { commentCtrl.text.trim().isEmpty ||
controller.selectedReimbursedBy.value == null) {
showAppSnackbar( showAppSnackbar(
title: "Incomplete", title: "Incomplete",
message: "Please fill all mandatory fields", message: "Please fill all mandatory fields, including 'Paid By'",
type: SnackbarType.warning, type: SnackbarType.warning,
); );
return; return;
@ -233,7 +234,6 @@ class _UpdatePaymentRequestWithReimbursementState
decoration: _inputDecoration("Enter transaction ID"), decoration: _inputDecoration("Enter transaction ID"),
), ),
MySpacing.height(16), MySpacing.height(16),
_requiredLabel("Transaction Date"), _requiredLabel("Transaction Date"),
MySpacing.height(8), MySpacing.height(8),
GestureDetector( GestureDetector(
@ -266,8 +266,7 @@ class _UpdatePaymentRequestWithReimbursementState
), ),
), ),
MySpacing.height(16), MySpacing.height(16),
_requiredLabel("Paid By"),
MyText.labelMedium("Paid By (Optional)"),
MySpacing.height(8), MySpacing.height(8),
GestureDetector( GestureDetector(
onTap: _showEmployeeList, onTap: _showEmployeeList,
@ -294,7 +293,6 @@ class _UpdatePaymentRequestWithReimbursementState
), ),
), ),
MySpacing.height(16), MySpacing.height(16),
_requiredLabel("Base Amount"), _requiredLabel("Base Amount"),
MySpacing.height(8), MySpacing.height(8),
TextField( TextField(
@ -303,7 +301,6 @@ class _UpdatePaymentRequestWithReimbursementState
decoration: _inputDecoration("Enter Base Amount"), decoration: _inputDecoration("Enter Base Amount"),
), ),
MySpacing.height(16), MySpacing.height(16),
_requiredLabel("GST Amount"), _requiredLabel("GST Amount"),
MySpacing.height(8), MySpacing.height(8),
TextField( TextField(
@ -312,7 +309,6 @@ class _UpdatePaymentRequestWithReimbursementState
decoration: _inputDecoration("Enter GST Amount"), decoration: _inputDecoration("Enter GST Amount"),
), ),
MySpacing.height(16), MySpacing.height(16),
MyText.labelMedium("TDS Percent"), MyText.labelMedium("TDS Percent"),
MySpacing.height(8), MySpacing.height(8),
TextField( TextField(
@ -335,7 +331,6 @@ class _UpdatePaymentRequestWithReimbursementState
color: Colors.grey.shade600, color: Colors.grey.shade600,
), ),
MySpacing.height(16), MySpacing.height(16),
Obx(() => Column( Obx(() => Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -353,7 +348,6 @@ class _UpdatePaymentRequestWithReimbursementState
], ],
)), )),
MySpacing.height(20), MySpacing.height(20),
_requiredLabel("Comment"), _requiredLabel("Comment"),
MySpacing.height(8), MySpacing.height(8),
TextField( TextField(