Changes in stop Cheque file before bank

This commit is contained in:
2026-01-15 13:29:59 +05:30
parent f024f200a4
commit 5f7852958b
2 changed files with 142 additions and 9 deletions

View File

@@ -31,9 +31,19 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
final _stopIssueDateController = TextEditingController();
final _stopExpiryDateController = TextEditingController();
final _stopAmountController = TextEditingController();
final _stopCommentController = TextEditingController();
final _chequeService = getIt<ChequeService>();
String? _selectedComment;
final _otherCommentController = TextEditingController();
bool _showOtherCommentField = false;
final List<String> _commentOptions = [
'Cheque Lost',
'Cheque Stolen',
'Cheque Missing',
'Cheque Damaged',
'Other'
];
String _formatDate(String dateString) {
if (dateString.length != 8) {
return dateString; // Return as is if not in expected ddmmyyyy format
@@ -48,6 +58,21 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
}
}
Future<void> _selectDate(TextEditingController controller) async {
final DateTime? picked = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime.now(),
lastDate: DateTime(2101),
);
if (picked != null) {
setState(() {
controller.text =
'${picked.day.toString().padLeft(2, '0')}/${picked.month.toString().padLeft(2, '0')}/${picked.year}';
});
}
}
Future<void> _showResponseDialog(String title, String message) async {
return showDialog<void>(
context: context,
@@ -107,6 +132,7 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
decoration: InputDecoration(
labelText: AppLocalizations.of(context).chequeNumberLabel,
border: OutlineInputBorder(),
errorMaxLines: 2,
),
keyboardType: TextInputType.number,
validator: (value) {
@@ -142,18 +168,30 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
const SizedBox(height: 16),
TextFormField(
controller: _stopIssueDateController,
readOnly: true,
onTap: () => _selectDate(_stopIssueDateController),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopIssueDateLabel,
border: const OutlineInputBorder(),
suffixIcon: IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () => _selectDate(_stopIssueDateController),
),
),
keyboardType: TextInputType.datetime,
),
const SizedBox(height: 16),
TextFormField(
controller: _stopExpiryDateController,
readOnly: true,
onTap: () => _selectDate(_stopExpiryDateController),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopExpiryDateLabel,
border: const OutlineInputBorder(),
suffixIcon: IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () => _selectDate(_stopExpiryDateController),
),
),
keyboardType: TextInputType.datetime,
),
@@ -167,13 +205,39 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
keyboardType: TextInputType.number,
),
const SizedBox(height: 16),
TextFormField(
controller: _stopCommentController,
DropdownButtonFormField<String>(
value: _selectedComment,
items: _commentOptions.map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (newValue) {
setState(() {
_selectedComment = newValue;
_showOtherCommentField = newValue == 'Other';
});
},
decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopCommentHint,
border: const OutlineInputBorder(),
),
),
if (_showOtherCommentField)
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: TextFormField(
controller: _otherCommentController,
decoration: const InputDecoration(
labelText: "Other Reasons :",
border: OutlineInputBorder(),
),
validator: (value) {
return null;
},
),
),
const SizedBox(height: 16),
TextFormField(
initialValue: _formatDate(widget.date),
@@ -205,7 +269,9 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
stopIssueDate: _stopIssueDateController.text,
stopExpiryDate: _stopExpiryDateController.text,
stopAmount: _stopAmountController.text,
stopComment: _stopCommentController.text,
stopComment: _selectedComment == 'Other'
? _otherCommentController.text
: _selectedComment ?? '',
chequeIssueDate: widget.date,
tpin: pin,
);
@@ -215,7 +281,7 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
final message = decodedResponse['message'];
if (status == 'SUCCESS') {
_showResponseDialog('Success', message);
} else {
} if (status == 'ERROR') {
_showResponseDialog('Error', message);
}
} on Exception catch (e) {