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

@@ -34,9 +34,19 @@ class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
final _stopIssueDateController = TextEditingController(); final _stopIssueDateController = TextEditingController();
final _stopExpiryDateController = TextEditingController(); final _stopExpiryDateController = TextEditingController();
final _stopAmountController = TextEditingController(); final _stopAmountController = TextEditingController();
final _stopCommentController = TextEditingController();
final _chequeService = getIt<ChequeService>(); 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) { String _formatDate(String dateString) {
if (dateString.length != 8) { if (dateString.length != 8) {
return dateString; // Return as is if not in expected ddmmyyyy format return dateString; // Return as is if not in expected ddmmyyyy format
@@ -51,6 +61,21 @@ class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
} }
} }
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 { Future<void> _showResponseDialog(String title, String message) async {
return showDialog<void>( return showDialog<void>(
context: context, context: context,
@@ -110,6 +135,7 @@ class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
decoration: InputDecoration( decoration: InputDecoration(
labelText: AppLocalizations.of(context).fromChequeNumberHint, labelText: AppLocalizations.of(context).fromChequeNumberHint,
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
errorMaxLines: 2,
), ),
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
validator: (value) { validator: (value) {
@@ -139,6 +165,7 @@ class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
decoration: InputDecoration( decoration: InputDecoration(
labelText: AppLocalizations.of(context).toChequeNumberHint, labelText: AppLocalizations.of(context).toChequeNumberHint,
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
errorMaxLines: 2,
), ),
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
validator: (value) { validator: (value) {
@@ -174,18 +201,30 @@ class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
const SizedBox(height: 16), const SizedBox(height: 16),
TextFormField( TextFormField(
controller: _stopIssueDateController, controller: _stopIssueDateController,
readOnly: true,
onTap: () => _selectDate(_stopIssueDateController),
decoration: InputDecoration( decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopIssueDateHint, labelText: AppLocalizations.of(context).stopIssueDateHint,
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
suffixIcon: IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () => _selectDate(_stopIssueDateController),
),
), ),
keyboardType: TextInputType.datetime, keyboardType: TextInputType.datetime,
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
TextFormField( TextFormField(
controller: _stopExpiryDateController, controller: _stopExpiryDateController,
readOnly: true,
onTap: () => _selectDate(_stopExpiryDateController),
decoration: InputDecoration( decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopExpiryDateHint, labelText: AppLocalizations.of(context).stopExpiryDateHint,
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
suffixIcon: IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () => _selectDate(_stopExpiryDateController),
),
), ),
keyboardType: TextInputType.datetime, keyboardType: TextInputType.datetime,
), ),
@@ -199,13 +238,39 @@ class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
TextFormField( DropdownButtonFormField<String>(
controller: _stopCommentController, 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( decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopCommentHint, labelText: AppLocalizations.of(context).stopCommentHint,
border: const OutlineInputBorder(), 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), const SizedBox(height: 16),
TextFormField( TextFormField(
initialValue: _formatDate(widget.date), initialValue: _formatDate(widget.date),
@@ -236,7 +301,9 @@ class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
stopIssueDate: _stopIssueDateController.text, stopIssueDate: _stopIssueDateController.text,
stopExpiryDate: _stopExpiryDateController.text, stopExpiryDate: _stopExpiryDateController.text,
stopAmount: _stopAmountController.text, stopAmount: _stopAmountController.text,
stopComment: _stopCommentController.text, stopComment: _selectedComment == 'Other'
? _otherCommentController.text
: _selectedComment ?? '',
chequeIssueDate: widget.date, chequeIssueDate: widget.date,
tpin: pin, tpin: pin,
); );

View File

@@ -31,9 +31,19 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
final _stopIssueDateController = TextEditingController(); final _stopIssueDateController = TextEditingController();
final _stopExpiryDateController = TextEditingController(); final _stopExpiryDateController = TextEditingController();
final _stopAmountController = TextEditingController(); final _stopAmountController = TextEditingController();
final _stopCommentController = TextEditingController();
final _chequeService = getIt<ChequeService>(); 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) { String _formatDate(String dateString) {
if (dateString.length != 8) { if (dateString.length != 8) {
return dateString; // Return as is if not in expected ddmmyyyy format 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 { Future<void> _showResponseDialog(String title, String message) async {
return showDialog<void>( return showDialog<void>(
context: context, context: context,
@@ -107,6 +132,7 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
decoration: InputDecoration( decoration: InputDecoration(
labelText: AppLocalizations.of(context).chequeNumberLabel, labelText: AppLocalizations.of(context).chequeNumberLabel,
border: OutlineInputBorder(), border: OutlineInputBorder(),
errorMaxLines: 2,
), ),
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
validator: (value) { validator: (value) {
@@ -142,18 +168,30 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
const SizedBox(height: 16), const SizedBox(height: 16),
TextFormField( TextFormField(
controller: _stopIssueDateController, controller: _stopIssueDateController,
readOnly: true,
onTap: () => _selectDate(_stopIssueDateController),
decoration: InputDecoration( decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopIssueDateLabel, labelText: AppLocalizations.of(context).stopIssueDateLabel,
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
suffixIcon: IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () => _selectDate(_stopIssueDateController),
),
), ),
keyboardType: TextInputType.datetime, keyboardType: TextInputType.datetime,
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
TextFormField( TextFormField(
controller: _stopExpiryDateController, controller: _stopExpiryDateController,
readOnly: true,
onTap: () => _selectDate(_stopExpiryDateController),
decoration: InputDecoration( decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopExpiryDateLabel, labelText: AppLocalizations.of(context).stopExpiryDateLabel,
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
suffixIcon: IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () => _selectDate(_stopExpiryDateController),
),
), ),
keyboardType: TextInputType.datetime, keyboardType: TextInputType.datetime,
), ),
@@ -167,13 +205,39 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
TextFormField( DropdownButtonFormField<String>(
controller: _stopCommentController, 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( decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopCommentHint, labelText: AppLocalizations.of(context).stopCommentHint,
border: const OutlineInputBorder(), 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), const SizedBox(height: 16),
TextFormField( TextFormField(
initialValue: _formatDate(widget.date), initialValue: _formatDate(widget.date),
@@ -205,7 +269,9 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
stopIssueDate: _stopIssueDateController.text, stopIssueDate: _stopIssueDateController.text,
stopExpiryDate: _stopExpiryDateController.text, stopExpiryDate: _stopExpiryDateController.text,
stopAmount: _stopAmountController.text, stopAmount: _stopAmountController.text,
stopComment: _stopCommentController.text, stopComment: _selectedComment == 'Other'
? _otherCommentController.text
: _selectedComment ?? '',
chequeIssueDate: widget.date, chequeIssueDate: widget.date,
tpin: pin, tpin: pin,
); );
@@ -215,7 +281,7 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
final message = decodedResponse['message']; final message = decodedResponse['message'];
if (status == 'SUCCESS') { if (status == 'SUCCESS') {
_showResponseDialog('Success', message); _showResponseDialog('Success', message);
} else { } if (status == 'ERROR') {
_showResponseDialog('Error', message); _showResponseDialog('Error', message);
} }
} on Exception catch (e) { } on Exception catch (e) {