Positive Pay fixed, yojna accounts created
This commit is contained in:
@@ -119,6 +119,7 @@ class BeneficiaryDetailsScreen extends StatelessWidget {
|
||||
beneficiary.ifscCode),
|
||||
_buildDetailRow('${AppLocalizations.of(context).branchName} ',
|
||||
beneficiary.branchName ?? 'N/A'),
|
||||
_buildDetailRow("Beneficiary Transactional Limit", beneficiary.transactionLimit ?? 'N/A'),
|
||||
const Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
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 PositivePayScreen extends StatefulWidget {
|
||||
@@ -16,25 +22,41 @@ class PositivePayScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PositivePayScreenState extends State<PositivePayScreen> {
|
||||
User? _selectedAccount;
|
||||
List<User> _filteredUsers = [];
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _accountNumberController = TextEditingController();
|
||||
final _chequeNumberController = TextEditingController();
|
||||
final _chequeDateController = TextEditingController();
|
||||
final _amountController = TextEditingController();
|
||||
final _payeeController = TextEditingController();
|
||||
final _chequeService = getIt<ChequeService>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_filteredUsers = widget.users
|
||||
.where((user) => ['SA', 'SB', 'CA', 'CC'].contains(user.accountType))
|
||||
.toList();
|
||||
// Pre-fill the account number if possible
|
||||
if (widget.users.isNotEmpty) {
|
||||
_accountNumberController.text = widget.users[widget.selectedIndex].accountNo!;
|
||||
if (widget.users.isNotEmpty && widget.selectedIndex < widget.users.length) {
|
||||
if (_filteredUsers.isNotEmpty) {
|
||||
if (_filteredUsers.contains(widget.users[widget.selectedIndex])) {
|
||||
_selectedAccount = widget.users[widget.selectedIndex];
|
||||
} else {
|
||||
_selectedAccount = _filteredUsers.first;
|
||||
}
|
||||
} else {
|
||||
_selectedAccount = widget.users[widget.selectedIndex];
|
||||
}
|
||||
} else {
|
||||
if (_filteredUsers.isNotEmpty) {
|
||||
_selectedAccount = _filteredUsers.first;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_accountNumberController.dispose();
|
||||
_chequeNumberController.dispose();
|
||||
_chequeDateController.dispose();
|
||||
_amountController.dispose();
|
||||
@@ -42,6 +64,33 @@ class _PositivePayScreenState extends State<PositivePayScreen> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
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: Text(AppLocalizations.of(context).closeButton),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -59,16 +108,26 @@ class _PositivePayScreenState extends State<PositivePayScreen> {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
const SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: _accountNumberController,
|
||||
DropdownButtonFormField<User>(
|
||||
value: _selectedAccount,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).accountNumber,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
items: _filteredUsers.map((user) {
|
||||
return DropdownMenuItem<User>(
|
||||
value: user,
|
||||
child: Text(user.accountNo.toString()),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (User? newUser) {
|
||||
setState(() {
|
||||
_selectedAccount = newUser;
|
||||
});
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter account number';
|
||||
if (value == null) {
|
||||
return AppLocalizations.of(context).accountNumberRequired;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -106,7 +165,7 @@ class _PositivePayScreenState extends State<PositivePayScreen> {
|
||||
);
|
||||
if (pickedDate != null) {
|
||||
// Format the date as you wish
|
||||
String formattedDate = "${pickedDate.day}-${pickedDate.month}-${pickedDate.year}";
|
||||
String formattedDate = "${pickedDate.year}-${pickedDate.month.toString().padLeft(2, '0')}-${pickedDate.day.toString().padLeft(2, '0')}";
|
||||
_chequeDateController.text = formattedDate;
|
||||
}
|
||||
},
|
||||
@@ -146,8 +205,58 @@ class _PositivePayScreenState extends State<PositivePayScreen> {
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
// Process data
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(AppLocalizations.of(context).processingData)),
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TransactionPinScreen(
|
||||
onPinCompleted: (ctx, pin) async {
|
||||
Navigator.pop(context);
|
||||
try {
|
||||
final response = await _chequeService.registerPPS(
|
||||
cheque_no: _chequeNumberController.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'){
|
||||
_showResponseDialog('REGISTRATION SUCCESFUL',
|
||||
'Your Positive Pay Request has been registered succesfully');
|
||||
}
|
||||
if(responseString.contains('Cheque already registered')){
|
||||
_showResponseDialog('ERROR',
|
||||
'Your Request for the selected cheque number has already been registered');
|
||||
}
|
||||
if(responseString.contains('INCORRECT_TPIN')){
|
||||
_showResponseDialog('Invalid TPIN',
|
||||
'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') &&
|
||||
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');
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:kmobile/features/account_opening/screens/account_opening_screen.dart';
|
||||
import 'package:kmobile/features/card/screens/card_management_screen.dart';
|
||||
import 'package:kmobile/features/service/screens/atm_locator_screen.dart';
|
||||
import 'package:kmobile/features/yojna/screens/pm_main_screen.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
@@ -71,28 +72,41 @@ class _ServiceScreen extends State<ServiceScreen> {
|
||||
disabled: false,
|
||||
),
|
||||
),
|
||||
// Expanded(
|
||||
// child: ServiceManagementTile(
|
||||
// icon: Symbols.box,
|
||||
// label: "Account Opening",
|
||||
// onTap: () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) => const AccountOpeningScreen()));
|
||||
// },
|
||||
// disabled: false,
|
||||
// ),
|
||||
// ),
|
||||
// Expanded(
|
||||
// child: ServiceManagementTile(
|
||||
// icon: Symbols.credit_card,
|
||||
// label: AppLocalizations.of(context).cardManagement,
|
||||
// onTap: () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) => const CardManagementScreen()));
|
||||
// },
|
||||
// disabled: false,
|
||||
// ),
|
||||
// ),
|
||||
Expanded(
|
||||
child: ServiceManagementTile(
|
||||
icon: Symbols.box,
|
||||
label: "Account Opening",
|
||||
icon: Symbols.family_group,
|
||||
label: "Pradhan Mantri Yojna",
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const AccountOpeningScreen()));
|
||||
},
|
||||
disabled: false,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ServiceManagementTile(
|
||||
icon: Symbols.credit_card,
|
||||
label: AppLocalizations.of(context).cardManagement,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const CardManagementScreen()));
|
||||
builder: (context) => const PMMainScreen()));
|
||||
},
|
||||
disabled: false,
|
||||
),
|
||||
|
||||
0
lib/features/yojna/screens/apy_screen.dart
Normal file
0
lib/features/yojna/screens/apy_screen.dart
Normal file
0
lib/features/yojna/screens/pm_create_screen.dart
Normal file
0
lib/features/yojna/screens/pm_create_screen.dart
Normal file
147
lib/features/yojna/screens/pm_main_screen.dart
Normal file
147
lib/features/yojna/screens/pm_main_screen.dart
Normal file
@@ -0,0 +1,147 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/l10n/app_localizations.dart';
|
||||
|
||||
class PMMainScreen extends StatefulWidget {
|
||||
const PMMainScreen({super.key});
|
||||
|
||||
@override
|
||||
State<PMMainScreen> createState() => _PMMainScreenState();
|
||||
}
|
||||
|
||||
class _PMMainScreenState extends State<PMMainScreen> {
|
||||
final TextEditingController _accountController = TextEditingController();
|
||||
String? _selectedScheme;
|
||||
|
||||
final List<String> _schemes = [
|
||||
'Pradhan Mantri Jeevan Jyoti Bima Yojana (PMJJBY)',
|
||||
'Pradhan Mantri Suraksha Bima Yojana (PMSBY)',
|
||||
];
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_accountController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Pradhan Mantri Yojana'),
|
||||
centerTitle: false,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Card(
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Text(
|
||||
"Create and Enquire about your Pradhan Mantri Jeevan Jyoti Bima Yojana (PMJJBY) and Pradhan Mantri Suraksha Bima Yojana(PMSBY) schemes.",
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextField(
|
||||
controller: _accountController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Account Number',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
DropdownButtonFormField<String>(
|
||||
value: _selectedScheme,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Scheme',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
items: _schemes.map((String scheme) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: scheme,
|
||||
child: Text(
|
||||
scheme,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (String? newValue) {
|
||||
setState(() {
|
||||
_selectedScheme = newValue;
|
||||
});
|
||||
},
|
||||
isExpanded: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
// Action for Create button
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.primaryContainer,
|
||||
foregroundColor:
|
||||
Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
elevation: 4,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
"Create",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
// Action for Enquiry button
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.primaryContainer,
|
||||
foregroundColor:
|
||||
Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
elevation: 4,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).enquiry,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
0
lib/features/yojna/screens/pmsby_screen.dart
Normal file
0
lib/features/yojna/screens/pmsby_screen.dart
Normal file
Reference in New Issue
Block a user