Revoke Stop base Created
This commit is contained in:
@@ -76,9 +76,9 @@ Dio _createDioClient() {
|
|||||||
final dio = Dio(
|
final dio = Dio(
|
||||||
BaseOptions(
|
BaseOptions(
|
||||||
baseUrl:
|
baseUrl:
|
||||||
// 'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com', //test
|
'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com', //test
|
||||||
//'http://lb-kccb-mobile-banking-app-848675342.ap-south-1.elb.amazonaws.com', //prod
|
//'http://lb-kccb-mobile-banking-app-848675342.ap-south-1.elb.amazonaws.com', //prod
|
||||||
'https://kccbmbnk.net', //prod small
|
//'https://kccbmbnk.net', //prod small
|
||||||
connectTimeout: const Duration(seconds: 60),
|
connectTimeout: const Duration(seconds: 60),
|
||||||
receiveTimeout: const Duration(seconds: 60),
|
receiveTimeout: const Duration(seconds: 60),
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class _ChequeManagementScreen extends State<ChequeManagementScreen> {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => RevokeStopSingleChequeScreen(
|
builder: (context) => RevokeStopChequeScreen(
|
||||||
users: users,
|
users: users,
|
||||||
selectedIndex: selectedAccountIndex,
|
selectedIndex: selectedAccountIndex,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -0,0 +1,337 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:kmobile/api/services/cheque_service.dart';
|
||||||
|
import 'package:kmobile/data/models/user.dart';
|
||||||
|
import 'package:kmobile/di/injection.dart';
|
||||||
|
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
|
||||||
|
import 'package:kmobile/l10n/app_localizations.dart';
|
||||||
|
|
||||||
|
class RevokeStopMultipleChequesScreen extends StatefulWidget {
|
||||||
|
final User selectedAccount;
|
||||||
|
final String date;
|
||||||
|
final String instrType;
|
||||||
|
final String fromCheque;
|
||||||
|
final String toCheque;
|
||||||
|
|
||||||
|
const RevokeStopMultipleChequesScreen(
|
||||||
|
{super.key,
|
||||||
|
required this.selectedAccount,
|
||||||
|
required this.date,
|
||||||
|
required this.instrType,
|
||||||
|
required this.fromCheque,
|
||||||
|
required this.toCheque});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RevokeStopMultipleChequesScreen> createState() =>
|
||||||
|
_RevokeStopMultipleChequesScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RevokeStopMultipleChequesScreenState extends State<RevokeStopMultipleChequesScreen> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
final _stopFromChequeNoController = TextEditingController();
|
||||||
|
final _stopToChequeNoController = TextEditingController();
|
||||||
|
final _stopIssueDateController = TextEditingController();
|
||||||
|
final _stopExpiryDateController = TextEditingController();
|
||||||
|
final _stopAmountController = TextEditingController();
|
||||||
|
final _chequeService = getIt<ChequeService>();
|
||||||
|
|
||||||
|
String? _selectedComment;
|
||||||
|
final _otherCommentController = TextEditingController();
|
||||||
|
bool _showOtherCommentField = false;
|
||||||
|
final List<String> _commentOptions = [
|
||||||
|
'Cheque Found',
|
||||||
|
'Cheque Fixed',
|
||||||
|
'Other'
|
||||||
|
];
|
||||||
|
|
||||||
|
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,
|
||||||
|
barrierDismissible: false, // user must tap button!
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(title),
|
||||||
|
content: SingleChildScrollView(
|
||||||
|
child: ListBody(
|
||||||
|
children: <Widget>[
|
||||||
|
Text(message),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Close'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(AppLocalizations.of(context).stopMultipleChequesTitle),
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: ListView(
|
||||||
|
children: [
|
||||||
|
Card(
|
||||||
|
elevation: 0,
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
|
child: ListTile(
|
||||||
|
leading: Image.asset(
|
||||||
|
'assets/images/logo.png',
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
),
|
||||||
|
title: Text(widget.selectedAccount.accountNo!),
|
||||||
|
subtitle:
|
||||||
|
Text(AppLocalizations.of(context).accountNumberTitle),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
TextFormField(
|
||||||
|
controller: _stopFromChequeNoController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: AppLocalizations.of(context).fromChequeNumberHint,
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
errorMaxLines: 2,
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
validator: (value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return AppLocalizations.of(context)
|
||||||
|
.pleaseEnterChequeNumberError;
|
||||||
|
}
|
||||||
|
final chequeNumber = int.tryParse(value);
|
||||||
|
final fromCheque = int.tryParse(widget.fromCheque);
|
||||||
|
final toCheque = int.tryParse(widget.toCheque);
|
||||||
|
if (chequeNumber == null ||
|
||||||
|
fromCheque == null ||
|
||||||
|
toCheque == null) {
|
||||||
|
return AppLocalizations.of(context)
|
||||||
|
.invalidChequeNumberFormatError;
|
||||||
|
}
|
||||||
|
// if (chequeNumber < fromCheque || chequeNumber > toCheque) {
|
||||||
|
// return AppLocalizations.of(context).chequeNumberRangeError(
|
||||||
|
// widget.fromCheque, widget.toCheque);
|
||||||
|
// }
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextFormField(
|
||||||
|
controller: _stopToChequeNoController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: AppLocalizations.of(context).toChequeNumberHint,
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
errorMaxLines: 2,
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
validator: (value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return AppLocalizations.of(context)
|
||||||
|
.pleaseEnterChequeNumberError;
|
||||||
|
}
|
||||||
|
final chequeNumber = int.tryParse(value);
|
||||||
|
final fromCheque = int.tryParse(widget.fromCheque);
|
||||||
|
final toCheque = int.tryParse(widget.toCheque);
|
||||||
|
if (chequeNumber == null ||
|
||||||
|
fromCheque == null ||
|
||||||
|
toCheque == null) {
|
||||||
|
return AppLocalizations.of(context)
|
||||||
|
.invalidChequeNumberFormatError;
|
||||||
|
}
|
||||||
|
// if (chequeNumber < fromCheque || chequeNumber > toCheque) {
|
||||||
|
// return AppLocalizations.of(context).chequeNumberRangeError(
|
||||||
|
// widget.fromCheque, widget.toCheque);
|
||||||
|
// }
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextFormField(
|
||||||
|
initialValue: widget.instrType,
|
||||||
|
readOnly: true,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: AppLocalizations.of(context).instrumentTypeLabel,
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextFormField(
|
||||||
|
controller: _stopIssueDateController,
|
||||||
|
readOnly: true,
|
||||||
|
onTap: () => _selectDate(_stopIssueDateController),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: AppLocalizations.of(context).stopIssueDateHint,
|
||||||
|
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).stopExpiryDateHint,
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
icon: const Icon(Icons.calendar_today),
|
||||||
|
onPressed: () => _selectDate(_stopExpiryDateController),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.datetime,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextFormField(
|
||||||
|
controller: _stopAmountController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: AppLocalizations.of(context).stopAmountHint,
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
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: 32),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
if (_formKey.currentState!.validate()) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => TransactionPinScreen(
|
||||||
|
onPinCompleted: (ctx, pin) async {
|
||||||
|
Navigator.pop(context);
|
||||||
|
try {
|
||||||
|
final response = await _chequeService.revokeStop(
|
||||||
|
accountno: widget.selectedAccount.accountNo!,
|
||||||
|
removeFromChequeNo:
|
||||||
|
_stopFromChequeNoController.text,
|
||||||
|
instrType: widget.instrType,
|
||||||
|
removeToChequeNo:
|
||||||
|
_stopToChequeNoController.text,
|
||||||
|
removeIssueDate: _stopIssueDateController.text,
|
||||||
|
removeExpiryDate: _stopExpiryDateController.text,
|
||||||
|
removeAmount: _stopAmountController.text,
|
||||||
|
removeComment: _selectedComment == 'Other'
|
||||||
|
? _otherCommentController.text
|
||||||
|
: _selectedComment ?? '',
|
||||||
|
tpin: pin,
|
||||||
|
);
|
||||||
|
if (!mounted) return;
|
||||||
|
final decodedResponse = jsonDecode(response);
|
||||||
|
String responseString = response.toString(); // used as the case only for incorrect TPIN
|
||||||
|
final status = decodedResponse['status'];
|
||||||
|
final message = decodedResponse['message'];
|
||||||
|
final code = decodedResponse['code'];
|
||||||
|
if (status == 'SUCCESS') {
|
||||||
|
_showResponseDialog('Success', message);
|
||||||
|
} if (status == 'ERROR') {
|
||||||
|
String errMessage = "error";
|
||||||
|
if(code == '0429') {
|
||||||
|
errMessage = 'The selected Cheque is already stopped';
|
||||||
|
} else if(code == '0748') {
|
||||||
|
errMessage = 'The selected Cheque is already presented';
|
||||||
|
}
|
||||||
|
_showResponseDialog('Error', errMessage);
|
||||||
|
}
|
||||||
|
if(responseString.contains('INCORRECT_TPIN')){
|
||||||
|
_showResponseDialog('Invalid TPIN',
|
||||||
|
'The TPIN you entered is incorrect. Please try again.');
|
||||||
|
}
|
||||||
|
} on Exception catch (e) {
|
||||||
|
try {
|
||||||
|
final errorBodyString =
|
||||||
|
e.toString().split('Exception: ')[1];
|
||||||
|
final errorBody = jsonDecode(errorBodyString);
|
||||||
|
if (errorBody.containsKey('error') &&
|
||||||
|
errorBody['error'] == 'INCORRECT_TPIN') {
|
||||||
|
_showResponseDialog('Invalid TPIN',
|
||||||
|
'The TPIN you entered is incorrect. Please try again.');
|
||||||
|
} else {
|
||||||
|
_showResponseDialog(
|
||||||
|
'Error', 'Internal Server Error');
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
_showResponseDialog(
|
||||||
|
'Error', 'Internal Server Error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(AppLocalizations.of(context).stopChequeButton),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ import 'package:kmobile/data/models/user.dart';
|
|||||||
import 'package:kmobile/di/injection.dart';
|
import 'package:kmobile/di/injection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kmobile/api/services/cheque_service.dart';
|
import 'package:kmobile/api/services/cheque_service.dart';
|
||||||
import 'package:kmobile/features/cheque/screens/stop_multiple_cheques_screen.dart';
|
import 'package:kmobile/features/cheque/screens/revoke%20_stop_multiple_screen.dart';
|
||||||
import 'package:kmobile/features/cheque/screens/stop_single_cheque_screen.dart';
|
import 'package:kmobile/features/cheque/screens/revoke_stop_single_screen.dart';
|
||||||
import 'package:kmobile/l10n/app_localizations.dart';
|
import 'package:kmobile/l10n/app_localizations.dart';
|
||||||
|
|
||||||
class RevokeStopSingleChequeScreen extends StatefulWidget {
|
class RevokeStopChequeScreen extends StatefulWidget {
|
||||||
final List<User> users;
|
final List<User> users;
|
||||||
final int selectedIndex;
|
final int selectedIndex;
|
||||||
|
|
||||||
const RevokeStopSingleChequeScreen(
|
const RevokeStopChequeScreen(
|
||||||
{
|
{
|
||||||
super.key,
|
super.key,
|
||||||
required this.users,
|
required this.users,
|
||||||
@@ -18,14 +18,14 @@ class RevokeStopSingleChequeScreen extends StatefulWidget {
|
|||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<RevokeStopSingleChequeScreen> createState() => _RevokeStopSingleChequeScreenState();
|
State<RevokeStopChequeScreen> createState() => _RevokeStopChequeScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScreen> {
|
class _RevokeStopChequeScreenState extends State<RevokeStopChequeScreen> {
|
||||||
User? _selectedAccount;
|
User? _selectedAccount;
|
||||||
var service = getIt<ChequeService>();
|
var service = getIt<ChequeService>();
|
||||||
bool _isLoading = true;
|
bool _isLoading = true;
|
||||||
Cheque? _stCheque;
|
List<Cheque> _stCheques = [];
|
||||||
List<User> _filteredUsers = [];
|
List<User> _filteredUsers = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -58,7 +58,7 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
|
|||||||
if (_selectedAccount == null) {
|
if (_selectedAccount == null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
_stCheque = null;
|
_stCheques = [];
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -87,13 +87,13 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
|
|||||||
accountNumber: _selectedAccount!.accountNo!, instrType: instrType);
|
accountNumber: _selectedAccount!.accountNo!, instrType: instrType);
|
||||||
final stCheques = data.where((cheque) => cheque.type == 'ST').toList();
|
final stCheques = data.where((cheque) => cheque.type == 'ST').toList();
|
||||||
setState(() {
|
setState(() {
|
||||||
_stCheque = stCheques.isNotEmpty ? stCheques.first : null;
|
_stCheques = stCheques;
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
_stCheque = null;
|
_stCheques = [];
|
||||||
});
|
});
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
@@ -122,15 +122,14 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(AppLocalizations.of(context).stopChequeTitle),
|
title: const Text("Revoke Stop Cheque"),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
),
|
),
|
||||||
body: Stack(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: Column(children: [
|
||||||
children: [
|
|
||||||
Card(
|
Card(
|
||||||
elevation: 4,
|
elevation: 4,
|
||||||
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
@@ -180,24 +179,25 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
|
|||||||
elevation: 4,
|
elevation: 4,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (_selectedAccount != null && _stCheque != null) {
|
if (_selectedAccount != null &&
|
||||||
|
_stCheques.isNotEmpty) {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => StopSingleChequeScreen(
|
builder: (context) =>
|
||||||
|
RevokeStopSingleChequeScreen(
|
||||||
selectedAccount: _selectedAccount!,
|
selectedAccount: _selectedAccount!,
|
||||||
date: _stCheque!.Date!,
|
date: _stCheques.first.Date!,
|
||||||
instrType: _stCheque!.InstrType!,
|
instrType: _stCheques.first.InstrType!,
|
||||||
fromCheque: _stCheque!.fromCheque!,
|
fromCheque: _stCheques.first.fromCheque!,
|
||||||
toCheque: _stCheque!.toCheque!,
|
toCheque: _stCheques.first.toCheque!,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
const SnackBar(
|
||||||
content: Text(AppLocalizations.of(context)
|
content: Text("No stopped cheques present"),
|
||||||
.noChequebookToStop),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -206,8 +206,7 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
|
|||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
AppLocalizations.of(context)
|
"Revoke Single Stop",
|
||||||
.stopSingleChequeTitle,
|
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
@@ -229,17 +228,18 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
|
|||||||
elevation: 4,
|
elevation: 4,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (_selectedAccount != null) {
|
if (_selectedAccount != null &&
|
||||||
|
_stCheques.isNotEmpty) {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
StopMultipleChequesScreen(
|
RevokeStopMultipleChequesScreen(
|
||||||
selectedAccount: _selectedAccount!,
|
selectedAccount: _selectedAccount!,
|
||||||
date: _stCheque!.Date!,
|
date: _stCheques.first.Date!,
|
||||||
instrType: _stCheque!.InstrType!,
|
instrType: _stCheques.first.InstrType!,
|
||||||
fromCheque: _stCheque!.fromCheque!,
|
fromCheque: _stCheques.first.fromCheque!,
|
||||||
toCheque: _stCheque!.toCheque!,
|
toCheque: _stCheques.first.toCheque!,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -256,8 +256,7 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
|
|||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
AppLocalizations.of(context)
|
"Revoke Multiple Stops",
|
||||||
.stopMultipleChequesButton,
|
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
@@ -278,14 +277,18 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: _isLoading
|
child: _isLoading
|
||||||
? const Center(child: CircularProgressIndicator())
|
? const Center(child: CircularProgressIndicator())
|
||||||
: _stCheque == null
|
: _stCheques.isEmpty
|
||||||
? Center(
|
? Center(
|
||||||
child: Text(AppLocalizations.of(context)
|
child: Text(AppLocalizations.of(context)
|
||||||
.noChequeIssuedStatus))
|
.noChequeIssuedStatus))
|
||||||
: _buildCiTile(context, _stCheque!),
|
: ListView.builder(
|
||||||
|
itemCount: _stCheques.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return _buildSTTile(context, _stCheques[index]);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
IgnorePointer(
|
IgnorePointer(
|
||||||
child: Center(
|
child: Center(
|
||||||
@@ -306,7 +309,7 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildCiTile(BuildContext context, Cheque cheque) {
|
Widget _buildSTTile(BuildContext context, Cheque cheque) {
|
||||||
return Card(
|
return Card(
|
||||||
margin: const EdgeInsets.symmetric(
|
margin: const EdgeInsets.symmetric(
|
||||||
vertical: 8.0,
|
vertical: 8.0,
|
||||||
@@ -316,20 +319,17 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(AppLocalizations.of(context).chequebookDetailsTitle,
|
Text(AppLocalizations.of(context).stopChequeLabel,
|
||||||
style: Theme.of(context).textTheme.titleLarge),
|
style: Theme.of(context).textTheme.titleLarge),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
_buildInfoRow('Account Number:', _selectedAccount!.accountNo!),
|
_buildInfoRow('From Cheque:', cheque.fromCheque),
|
||||||
_buildInfoRow('Customer Name:', _selectedAccount!.name!),
|
_buildInfoRow('To Cheque:', cheque.toCheque),
|
||||||
_buildInfoRow('CIF Number:', _selectedAccount!.cifNumber!),
|
|
||||||
_buildInfoRow('Account Type:',
|
_buildInfoRow('Account Type:',
|
||||||
_getAccountTypeDisplayName(_selectedAccount!.accountType!)),
|
_getAccountTypeDisplayName(_selectedAccount!.accountType!)),
|
||||||
_buildInfoRow('Branch Code:', cheque.branchCode),
|
_buildInfoRow('Branch Code:', cheque.branchCode),
|
||||||
_buildInfoRow('Starting Cheque Number:', cheque.fromCheque),
|
_buildInfoRow('Stop Issue Date:', cheque.stopIssueDate),
|
||||||
_buildInfoRow('Ending Cheque Number:', cheque.toCheque),
|
_buildInfoRow('Stop Expiry Date:', cheque.StopExpiryDate),
|
||||||
_buildInfoRow('Issue Date:', cheque.Date),
|
_buildInfoRow('Cheques Count:', cheque.Chequescount),
|
||||||
_buildInfoRow('Number of Cheques:', cheque.Chequescount),
|
|
||||||
_buildInfoRow('Instrument Type:', cheque.InstrType),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,331 +1,304 @@
|
|||||||
// import 'dart:convert';
|
import 'dart:convert';
|
||||||
// import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
// import 'package:kmobile/data/models/user.dart';
|
import 'package:kmobile/data/models/user.dart';
|
||||||
// import 'package:kmobile/di/injection.dart';
|
import 'package:kmobile/di/injection.dart';
|
||||||
// import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
// import 'package:kmobile/api/services/cheque_service.dart';
|
import 'package:kmobile/api/services/cheque_service.dart';
|
||||||
// import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
|
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
|
||||||
// import 'package:kmobile/l10n/app_localizations.dart';
|
import 'package:kmobile/l10n/app_localizations.dart';
|
||||||
|
|
||||||
// class RevokeStopSingleChequeScreen extends StatefulWidget {
|
class RevokeStopSingleChequeScreen extends StatefulWidget {
|
||||||
// final User selectedAccount;
|
final User selectedAccount;
|
||||||
// final String date;
|
final String date;
|
||||||
// final String instrType;
|
final String instrType;
|
||||||
// final String fromCheque;
|
final String fromCheque;
|
||||||
// final String toCheque;
|
final String toCheque;
|
||||||
|
|
||||||
// const RevokeStopSingleChequeScreen(
|
const RevokeStopSingleChequeScreen(
|
||||||
// {super.key,
|
{super.key,
|
||||||
// required this.selectedAccount,
|
required this.selectedAccount,
|
||||||
// required this.date,
|
required this.date,
|
||||||
// required this.instrType,
|
required this.instrType,
|
||||||
// required this.fromCheque,
|
required this.fromCheque,
|
||||||
// required this.toCheque});
|
required this.toCheque});
|
||||||
|
|
||||||
// @override
|
@override
|
||||||
// State<RevokeStopSingleChequeScreen> createState() => _RevokeStopSingleChequeScreenState();
|
State<RevokeStopSingleChequeScreen> createState() => _RevokeStopSingleChequeScreenState();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScreen> {
|
class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScreen> {
|
||||||
// final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
// final _stopFromChequeNoController = TextEditingController();
|
final _stopFromChequeNoController = TextEditingController();
|
||||||
// final _stopIssueDateController = TextEditingController();
|
final _stopIssueDateController = TextEditingController();
|
||||||
// final _stopExpiryDateController = TextEditingController();
|
final _stopExpiryDateController = TextEditingController();
|
||||||
// final _stopAmountController = TextEditingController();
|
final _stopAmountController = TextEditingController();
|
||||||
// final _chequeService = getIt<ChequeService>();
|
final _chequeService = getIt<ChequeService>();
|
||||||
|
|
||||||
// String? _selectedComment;
|
String? _selectedComment;
|
||||||
// final _otherCommentController = TextEditingController();
|
final _otherCommentController = TextEditingController();
|
||||||
// bool _showOtherCommentField = false;
|
bool _showOtherCommentField = false;
|
||||||
// final List<String> _commentOptions = [
|
final List<String> _commentOptions = [
|
||||||
// 'Cheque Lost',
|
'Cheque Found',
|
||||||
// 'Cheque Stolen',
|
'Cheque Fixed',
|
||||||
// 'Cheque Missing',
|
'Other'
|
||||||
// 'Cheque Damaged',
|
];
|
||||||
// 'Other'
|
|
||||||
// ];
|
|
||||||
|
|
||||||
// String _formatDate(String dateString) {
|
Future<void> _selectDate(TextEditingController controller) async {
|
||||||
// if (dateString.length != 8) {
|
final DateTime? picked = await showDatePicker(
|
||||||
// return dateString; // Return as is if not in expected ddmmyyyy format
|
context: context,
|
||||||
// }
|
initialDate: DateTime.now(),
|
||||||
// try {
|
firstDate: DateTime.now(),
|
||||||
// final day = dateString.substring(0, 2);
|
lastDate: DateTime(2101),
|
||||||
// final month = dateString.substring(2, 4);
|
);
|
||||||
// final year = dateString.substring(4, 8);
|
if (picked != null) {
|
||||||
// return '$day/$month/$year';
|
setState(() {
|
||||||
// } catch (e) {
|
controller.text =
|
||||||
// return dateString; // Return original string on error
|
'${picked.day.toString().padLeft(2, '0')}/${picked.month.toString().padLeft(2, '0')}/${picked.year}';
|
||||||
// }
|
});
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Future<void> _selectDate(TextEditingController controller) async {
|
Future<void> _showResponseDialog(String title, String message) async {
|
||||||
// final DateTime? picked = await showDatePicker(
|
return showDialog<void>(
|
||||||
// context: context,
|
context: context,
|
||||||
// initialDate: DateTime.now(),
|
barrierDismissible: false, // user must tap button!
|
||||||
// firstDate: DateTime.now(),
|
builder: (BuildContext context) {
|
||||||
// lastDate: DateTime(2101),
|
return AlertDialog(
|
||||||
// );
|
title: Text(title),
|
||||||
// if (picked != null) {
|
content: SingleChildScrollView(
|
||||||
// setState(() {
|
child: ListBody(
|
||||||
// controller.text =
|
children: <Widget>[
|
||||||
// '${picked.day.toString().padLeft(2, '0')}/${picked.month.toString().padLeft(2, '0')}/${picked.year}';
|
Text(message),
|
||||||
// });
|
],
|
||||||
// }
|
),
|
||||||
// }
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
child: Text(AppLocalizations.of(context).closeButton),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Future<void> _showResponseDialog(String title, String message) async {
|
@override
|
||||||
// return showDialog<void>(
|
Widget build(BuildContext context) {
|
||||||
// context: context,
|
return Scaffold(
|
||||||
// barrierDismissible: false, // user must tap button!
|
appBar: AppBar(
|
||||||
// builder: (BuildContext context) {
|
title: const Text("Revoke Single Stop")),
|
||||||
// return AlertDialog(
|
body: Padding(
|
||||||
// title: Text(title),
|
padding: const EdgeInsets.all(16.0),
|
||||||
// content: SingleChildScrollView(
|
child: Form(
|
||||||
// child: ListBody(
|
key: _formKey,
|
||||||
// children: <Widget>[
|
child: ListView(
|
||||||
// Text(message),
|
children: [
|
||||||
// ],
|
Card(
|
||||||
// ),
|
elevation: 0,
|
||||||
// ),
|
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
// actions: <Widget>[
|
child: ListTile(
|
||||||
// TextButton(
|
leading: Image.asset(
|
||||||
// child: Text(AppLocalizations.of(context).closeButton),
|
'assets/images/logo.png',
|
||||||
// onPressed: () {
|
width: 40,
|
||||||
// Navigator.of(context).pop();
|
height: 40,
|
||||||
// },
|
),
|
||||||
// ),
|
title: Text(widget.selectedAccount.accountNo!),
|
||||||
// ],
|
subtitle:
|
||||||
// );
|
Text(AppLocalizations.of(context).accountNumberLabel),
|
||||||
// },
|
),
|
||||||
// );
|
),
|
||||||
// }
|
const SizedBox(height: 24),
|
||||||
|
TextFormField(
|
||||||
// @override
|
controller: _stopFromChequeNoController,
|
||||||
// Widget build(BuildContext context) {
|
decoration: InputDecoration(
|
||||||
// return Scaffold(
|
labelText: AppLocalizations.of(context).chequeNumberLabel,
|
||||||
// appBar: AppBar(
|
border: const OutlineInputBorder(),
|
||||||
// title: const Text("Revoke Stop")),
|
errorMaxLines: 2,
|
||||||
// );
|
),
|
||||||
// body: Padding(
|
keyboardType: TextInputType.number,
|
||||||
// padding: const EdgeInsets.all(16.0),
|
validator: (value) {
|
||||||
// child: Form(
|
if (value == null || value.isEmpty) {
|
||||||
// key: _formKey,
|
return AppLocalizations.of(context)
|
||||||
// child: ListView(
|
.pleaseEnterChequeNumberError;
|
||||||
// children: [
|
}
|
||||||
// Card(
|
final chequeNumber = int.tryParse(value);
|
||||||
// elevation: 0,
|
final fromCheque = int.tryParse(widget.fromCheque);
|
||||||
// margin: const EdgeInsets.symmetric(vertical: 8.0),
|
final toCheque = int.tryParse(widget.toCheque);
|
||||||
// child: ListTile(
|
if (chequeNumber == null ||
|
||||||
// leading: Image.asset(
|
fromCheque == null ||
|
||||||
// 'assets/images/logo.png',
|
toCheque == null) {
|
||||||
// width: 40,
|
return AppLocalizations.of(context)
|
||||||
// height: 40,
|
.invalidChequeNumberFormatError;
|
||||||
// ),
|
}
|
||||||
// title: Text(widget.selectedAccount.accountNo!),
|
|
||||||
// subtitle:
|
|
||||||
// Text(AppLocalizations.of(context).accountNumberLabel),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// const SizedBox(height: 24),
|
|
||||||
// TextFormField(
|
|
||||||
// controller: _stopFromChequeNoController,
|
|
||||||
// decoration: InputDecoration(
|
|
||||||
// labelText: AppLocalizations.of(context).chequeNumberLabel,
|
|
||||||
// border: OutlineInputBorder(),
|
|
||||||
// errorMaxLines: 2,
|
|
||||||
// ),
|
|
||||||
// keyboardType: TextInputType.number,
|
|
||||||
// validator: (value) {
|
|
||||||
// if (value == null || value.isEmpty) {
|
|
||||||
// return AppLocalizations.of(context)
|
|
||||||
// .pleaseEnterChequeNumberError;
|
|
||||||
// }
|
|
||||||
// final chequeNumber = int.tryParse(value);
|
|
||||||
// final fromCheque = int.tryParse(widget.fromCheque);
|
|
||||||
// final toCheque = int.tryParse(widget.toCheque);
|
|
||||||
// if (chequeNumber == null ||
|
|
||||||
// fromCheque == null ||
|
|
||||||
// toCheque == null) {
|
|
||||||
// return AppLocalizations.of(context)
|
|
||||||
// .invalidChequeNumberFormatError;
|
|
||||||
// }
|
|
||||||
// if (chequeNumber < fromCheque || chequeNumber > toCheque) {
|
// if (chequeNumber < fromCheque || chequeNumber > toCheque) {
|
||||||
// return AppLocalizations.of(context).chequeNumberRangeError(
|
// return AppLocalizations.of(context).chequeNumberRangeError(
|
||||||
// widget.fromCheque, widget.toCheque);
|
// widget.fromCheque, widget.toCheque);
|
||||||
// }
|
// }
|
||||||
// return null;
|
return null;
|
||||||
// },
|
},
|
||||||
// ),
|
),
|
||||||
// const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
// TextFormField(
|
TextFormField(
|
||||||
// initialValue: widget.instrType,
|
initialValue: widget.instrType,
|
||||||
// readOnly: true,
|
readOnly: true,
|
||||||
// decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
// labelText: AppLocalizations.of(context).instrumentTypeLabel,
|
labelText: AppLocalizations.of(context).instrumentTypeLabel,
|
||||||
// border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
// TextFormField(
|
TextFormField(
|
||||||
// controller: _stopIssueDateController,
|
controller: _stopIssueDateController,
|
||||||
// readOnly: true,
|
readOnly: true,
|
||||||
// onTap: () => _selectDate(_stopIssueDateController),
|
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(
|
suffixIcon: IconButton(
|
||||||
// icon: const Icon(Icons.calendar_today),
|
icon: const Icon(Icons.calendar_today),
|
||||||
// onPressed: () => _selectDate(_stopIssueDateController),
|
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,
|
readOnly: true,
|
||||||
// onTap: () => _selectDate(_stopExpiryDateController),
|
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(
|
suffixIcon: IconButton(
|
||||||
// icon: const Icon(Icons.calendar_today),
|
icon: const Icon(Icons.calendar_today),
|
||||||
// onPressed: () => _selectDate(_stopExpiryDateController),
|
onPressed: () => _selectDate(_stopExpiryDateController),
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// keyboardType: TextInputType.datetime,
|
keyboardType: TextInputType.datetime,
|
||||||
// ),
|
),
|
||||||
// const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
// TextFormField(
|
TextFormField(
|
||||||
// controller: _stopAmountController,
|
controller: _stopAmountController,
|
||||||
// decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
// labelText: AppLocalizations.of(context).stopAmountHint,
|
labelText: AppLocalizations.of(context).stopAmountHint,
|
||||||
// border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
// ),
|
),
|
||||||
// keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
// ),
|
),
|
||||||
// const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
// DropdownButtonFormField<String>(
|
DropdownButtonFormField<String>(
|
||||||
// value: _selectedComment,
|
value: _selectedComment,
|
||||||
// items: _commentOptions.map((String value) {
|
items: _commentOptions.map((String value) {
|
||||||
// return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
// value: value,
|
value: value,
|
||||||
// child: Text(value),
|
child: Text(value),
|
||||||
// );
|
);
|
||||||
// }).toList(),
|
}).toList(),
|
||||||
// onChanged: (newValue) {
|
onChanged: (newValue) {
|
||||||
// setState(() {
|
setState(() {
|
||||||
// _selectedComment = newValue;
|
_selectedComment = newValue;
|
||||||
// _showOtherCommentField = newValue == 'Other';
|
_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)
|
if (_showOtherCommentField)
|
||||||
// Padding(
|
Padding(
|
||||||
// padding: const EdgeInsets.only(top: 16.0),
|
padding: const EdgeInsets.only(top: 16.0),
|
||||||
// child: TextFormField(
|
child: TextFormField(
|
||||||
// controller: _otherCommentController,
|
controller: _otherCommentController,
|
||||||
// decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
// labelText: "Other Reasons :",
|
labelText: "Other Reasons :",
|
||||||
// border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
// ),
|
),
|
||||||
// validator: (value) {
|
validator: (value) {
|
||||||
// return null;
|
return null;
|
||||||
// },
|
},
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// const SizedBox(height: 16),
|
const SizedBox(height: 32),
|
||||||
// TextFormField(
|
ElevatedButton(
|
||||||
// initialValue: _formatDate(widget.date),
|
onPressed: () {
|
||||||
// readOnly: true,
|
if (_formKey.currentState!.validate()) {
|
||||||
// decoration: InputDecoration(
|
Navigator.push(
|
||||||
// labelText:
|
context,
|
||||||
// AppLocalizations.of(context).chequebookIssueDateHint,
|
MaterialPageRoute(
|
||||||
// border: const OutlineInputBorder(),
|
builder: (context) => TransactionPinScreen(
|
||||||
// ),
|
onPinCompleted: (ctx, pin) async {
|
||||||
// ),
|
Navigator.pop(context);
|
||||||
// const SizedBox(height: 32),
|
try {
|
||||||
// ElevatedButton(
|
final response = await _chequeService.revokeStop(
|
||||||
// onPressed: () {
|
accountno: widget.selectedAccount.accountNo!,
|
||||||
// if (_formKey.currentState!.validate()) {
|
removeFromChequeNo:
|
||||||
// Navigator.push(
|
_stopFromChequeNoController.text,
|
||||||
// context,
|
instrType: widget.instrType,
|
||||||
// MaterialPageRoute(
|
removeToChequeNo:
|
||||||
// builder: (context) => TransactionPinScreen(
|
_stopFromChequeNoController.text,
|
||||||
// onPinCompleted: (ctx, pin) async {
|
removeIssueDate: _stopIssueDateController.text,
|
||||||
// Navigator.pop(context);
|
removeExpiryDate: _stopExpiryDateController.text,
|
||||||
// try {
|
removeAmount: _stopAmountController.text,
|
||||||
// final response = await _chequeService.revokeStop(
|
removeComment: _selectedComment == 'Other'
|
||||||
// accountno: widget.selectedAccount.accountNo!,
|
? _otherCommentController.text
|
||||||
// stopFromChequeNo:
|
: _selectedComment ?? '',
|
||||||
// _stopFromChequeNoController.text,
|
tpin: pin,
|
||||||
// instrType: widget.instrType,
|
);
|
||||||
// stopToChequeNo:
|
if (!mounted) return;
|
||||||
// _stopFromChequeNoController.text,
|
final decodedResponse = jsonDecode(response);
|
||||||
// stopIssueDate: _stopIssueDateController.text,
|
String responseString = response.toString(); // used as the case only for incorrect TPIN
|
||||||
// stopExpiryDate: _stopExpiryDateController.text,
|
final status = decodedResponse['status'];
|
||||||
// stopAmount: _stopAmountController.text,
|
final message = decodedResponse['message'];
|
||||||
// stopComment: _selectedComment == 'Other'
|
final code = decodedResponse['code'];
|
||||||
// ? _otherCommentController.text
|
if (status == 'SUCCESS') {
|
||||||
// : _selectedComment ?? '',
|
_showResponseDialog('Success', message);
|
||||||
// chequeIssueDate: widget.date,
|
} if (status == 'ERROR') {
|
||||||
// tpin: pin,
|
String errMessage = "error";
|
||||||
// );
|
if(code == '0429') {
|
||||||
// if (!mounted) return;
|
errMessage = 'The selected Cheque is already stopped';
|
||||||
// final decodedResponse = jsonDecode(response);
|
} else if(code == '0748') {
|
||||||
// String responseString = response.toString(); // used as the case only for incorrect TPIN
|
errMessage = 'The selected Cheque is already presented';
|
||||||
// final status = decodedResponse['status'];
|
}
|
||||||
// final message = decodedResponse['message'];
|
_showResponseDialog('Error', errMessage);
|
||||||
// final code = decodedResponse['code'];
|
}
|
||||||
// if (status == 'SUCCESS') {
|
if(responseString.contains('INCORRECT_TPIN')){
|
||||||
// _showResponseDialog('Success', message);
|
_showResponseDialog('Invalid TPIN',
|
||||||
// } if (status == 'ERROR') {
|
'The TPIN you entered is incorrect. Please try again.');
|
||||||
// String errMessage = "error";
|
}
|
||||||
// if(code == '0429') {
|
} on DioException catch (e) {
|
||||||
// errMessage = 'The selected Cheque is already stopped';
|
try {
|
||||||
// } else if(code == '0748') {
|
final errorBodyString =
|
||||||
// errMessage = 'The selected Cheque is already presented';
|
e.toString().split('Exception: ')[1];
|
||||||
// }
|
final errorBody = jsonDecode(errorBodyString);
|
||||||
// _showResponseDialog('Error', errMessage);
|
if (errorBody.containsKey('error') &&
|
||||||
// }
|
errorBody['error'] == 'INCORRECT_TPIN') {
|
||||||
// if(responseString.contains('INCORRECT_TPIN')){
|
_showResponseDialog('Invalid TPIN',
|
||||||
// _showResponseDialog('Invalid TPIN',
|
'The TPIN you entered is incorrect. Please try again.');
|
||||||
// 'The TPIN you entered is incorrect. Please try again.');
|
} else {
|
||||||
// }
|
_showResponseDialog(
|
||||||
// } on DioException catch (e) {
|
'Error', 'Internal Server Error');
|
||||||
// try {
|
}
|
||||||
// final errorBodyString =
|
} catch (_) {
|
||||||
// e.toString().split('Exception: ')[1];
|
_showResponseDialog(
|
||||||
// final errorBody = jsonDecode(errorBodyString);
|
'Error', 'Internal Server Error');
|
||||||
// if (errorBody.containsKey('error') &&
|
}
|
||||||
// errorBody['error'] == 'INCORRECT_TPIN') {
|
}
|
||||||
// _showResponseDialog('Invalid TPIN',
|
},
|
||||||
// 'The TPIN you entered is incorrect. Please try again.');
|
),
|
||||||
// } else {
|
),
|
||||||
// _showResponseDialog(
|
);
|
||||||
// 'Error', 'Internal Server Error');
|
}
|
||||||
// }
|
},
|
||||||
// } catch (_) {
|
child: Text("Revoke Stop"),
|
||||||
// _showResponseDialog(
|
),
|
||||||
// 'Error', 'Internal Server Error');
|
],
|
||||||
// }
|
),
|
||||||
// }
|
),
|
||||||
// },
|
),
|
||||||
// ),
|
);
|
||||||
// ),
|
}
|
||||||
// );
|
}
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// child: Text("Revoke Stop"),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user