APY integrated without testing...

This commit is contained in:
2026-03-18 12:36:41 +05:30
parent 075cb3aaad
commit 8744e69ef7
29 changed files with 1069 additions and 498 deletions

View File

@@ -36,7 +36,7 @@ class _PositivePayScreenState extends State<PositivePayScreen> {
@override
void initState() {
super.initState();
_filteredUsers = widget.users
_filteredUsers = widget.users
.where((user) => ['SA', 'SB', 'CA', 'CC'].contains(user.accountType))
.toList();
// Pre-fill the account number if possible
@@ -113,7 +113,7 @@ class _PositivePayScreenState extends State<PositivePayScreen> {
super.dispose();
}
Future<void> _showResponseDialog(String title, String message) async {
Future<void> _showResponseDialog(String title, String message) async {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
@@ -145,7 +145,8 @@ Future<void> _showResponseDialog(String title, String message) async {
return Scaffold(
appBar: AppBar(
title: Text(
AppLocalizations.of(context).positivePay, // Will be replaced by localization
AppLocalizations.of(context)
.positivePay, // Will be replaced by localization
),
centerTitle: false,
),
@@ -199,12 +200,13 @@ Future<void> _showResponseDialog(String title, String message) async {
final fromCheque = int.tryParse(_ciFromCheque ?? '');
final toCheque = int.tryParse(_ciToCheque ?? '');
if (chequeNumber == null) {
return AppLocalizations.of(context).invalidChequeNumberFormatError;
return AppLocalizations.of(context)
.invalidChequeNumberFormatError;
}
if (fromCheque != null && toCheque != null) {
if (chequeNumber < fromCheque || chequeNumber > toCheque) {
return AppLocalizations.of(context).chequeNumberRangeError(
_ciFromCheque!, _ciToCheque!);
return AppLocalizations.of(context)
.chequeNumberRangeError(_ciFromCheque!, _ciToCheque!);
}
}
return null;
@@ -228,13 +230,15 @@ Future<void> _showResponseDialog(String title, String message) async {
);
if (pickedDate != null) {
// Format the date as you wish
String formattedDate = "${pickedDate.year}-${pickedDate.month.toString().padLeft(2, '0')}-${pickedDate.day.toString().padLeft(2, '0')}";
String formattedDate =
"${pickedDate.year}-${pickedDate.month.toString().padLeft(2, '0')}-${pickedDate.day.toString().padLeft(2, '0')}";
_chequeDateController.text = formattedDate;
}
},
validator: (value) {
validator: (value) {
if (value == null || value.isEmpty) {
return AppLocalizations.of(context).pleaseSelectChequeIssuedDate;
return AppLocalizations.of(context)
.pleaseSelectChequeIssuedDate;
}
return null;
},
@@ -255,7 +259,8 @@ Future<void> _showResponseDialog(String title, String message) async {
border: const OutlineInputBorder(),
prefixText: '',
),
keyboardType: const TextInputType.numberWithOptions(decimal: true),
keyboardType:
const TextInputType.numberWithOptions(decimal: true),
validator: (value) {
if (value == null || value.isEmpty) {
return AppLocalizations.of(context).pleaseEnterAmount;
@@ -277,34 +282,34 @@ Future<void> _showResponseDialog(String title, String message) async {
try {
final response = await _chequeService.registerPPS(
cheque_no: _chequeNumberController.text,
account_number:
_selectedAccount!.accountNo!,
issue_date:
_chequeDateController.text,
account_number: _selectedAccount!.accountNo!,
issue_date: _chequeDateController.text,
amount: _amountController.text,
payee_name: _payeeController.text,
tpin: pin,
);
if (!mounted) return;
String responseString = response.toString();
if(responseString == 'PPS Registered Successfully'){
if (responseString ==
'PPS Registered Successfully') {
_showResponseDialog('REGISTRATION SUCCESFUL',
'Your Positive Pay Request has been registered succesfully');
'Your Positive Pay Request has been registered succesfully');
}
if(responseString.contains('Cheque already registered')){
if (responseString
.contains('Cheque already registered')) {
_showResponseDialog('ERROR',
'Your Request for the selected cheque number has already been registered');
'Your Request for the selected cheque number has already been registered');
}
if(responseString.contains('INCORRECT_TPIN')){
if (responseString.contains('INCORRECT_TPIN')) {
_showResponseDialog('Invalid TPIN',
'The TPIN you entered is incorrect. Please try again.');
'The TPIN you entered is incorrect. Please try again.');
}
} on DioException catch (e) {
try {
final errorBodyString =
e.toString().split('Exception: ')[1];
final errorBody = jsonDecode(errorBodyString);
if (errorBody.containsKey('error') &&
final errorBody = jsonDecode(errorBodyString);
if (errorBody.containsKey('error') &&
errorBody['error'] == 'INCORRECT_TPIN') {
_showResponseDialog('Invalid TPIN',
'The TPIN you entered is incorrect. Please try again.');