Test APK build

This commit is contained in:
2025-12-31 11:45:21 +05:30
parent 9d8c8dc8bd
commit 60270a5fa9
3 changed files with 129 additions and 58 deletions

View File

@@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
class Cheque { class Cheque {
final String? type; final String? type;
@@ -104,9 +106,16 @@ class ChequeService {
String? stopAmount, String? stopAmount,
String? stopComment, String? stopComment,
String? chequeIssueDate, String? chequeIssueDate,
required String tpin,
}) async { }) async {
final response = await _dio.post( final response = await _dio.post(
'/api/cheque/stop', '/api/cheque/stop',
options: Options(
validateStatus: (int? status) => true,
receiveDataWhenStatusError: true,
),
data: { data: {
'accountNumber': accountno, 'accountNumber': accountno,
'stopFromChequeNo': stopFromChequeNo, 'stopFromChequeNo': stopFromChequeNo,
@@ -117,10 +126,11 @@ class ChequeService {
'stopAmount': stopAmount, 'stopAmount': stopAmount,
'stopComment': stopComment, 'stopComment': stopComment,
'chqIssueDate': chequeIssueDate, 'chqIssueDate': chequeIssueDate,
'tpin':tpin,
}, },
); );
if (response.statusCode != 200) { if (response.statusCode != 200) {
throw Exception("Error"); throw Exception(jsonEncode(response.data));
} }
return response.toString(); return response.toString();
} }

View File

@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:kmobile/api/services/cheque_service.dart'; import 'package:kmobile/api/services/cheque_service.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:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
class StopMultipleChequesScreen extends StatefulWidget { class StopMultipleChequesScreen extends StatefulWidget {
final User selectedAccount; final User selectedAccount;
@@ -81,7 +82,7 @@ class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Stop Single Cheque'), title: const Text('Stop Multiple Cheques'),
), ),
body: Padding( body: Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
@@ -209,19 +210,29 @@ class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
), ),
const SizedBox(height: 32), const SizedBox(height: 32),
ElevatedButton( ElevatedButton(
onPressed: () async { onPressed: () {
if (_formKey.currentState!.validate()) { if (_formKey.currentState!.validate()) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TransactionPinScreen(
onPinCompleted: (ctx, pin) async {
Navigator.pop(context);
try { try {
final response = await _chequeService.stopCheque( final response = await _chequeService.stopCheque(
accountno: widget.selectedAccount.accountNo!, accountno: widget.selectedAccount.accountNo!,
stopFromChequeNo: _stopFromChequeNoController.text, stopFromChequeNo:
_stopFromChequeNoController.text,
instrType: widget.instrType, instrType: widget.instrType,
stopToChequeNo: _stopToChequeNoController.text, stopToChequeNo:
_stopToChequeNoController.text,
stopIssueDate: _stopIssueDateController.text, stopIssueDate: _stopIssueDateController.text,
stopExpiryDate: _stopExpiryDateController.text, stopExpiryDate:
_stopExpiryDateController.text,
stopAmount: _stopAmountController.text, stopAmount: _stopAmountController.text,
stopComment: _stopCommentController.text, stopComment: _stopCommentController.text,
chequeIssueDate: widget.date, chequeIssueDate: widget.date,
tpin: pin,
); );
if (!mounted) return; if (!mounted) return;
final decodedResponse = jsonDecode(response); final decodedResponse = jsonDecode(response);
@@ -232,9 +243,29 @@ class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
} else { } else {
_showResponseDialog('Error', message); _showResponseDialog('Error', message);
} }
} catch (e) { } on Exception catch (e) {
_showResponseDialog('Error', e.toString()); print('inside catch block');
print(e.toString());
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: const Text('Stop Cheque'), child: const Text('Stop Cheque'),

View File

@@ -1,9 +1,9 @@
import 'dart:convert'; 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/data/models/user.dart';
import 'package:kmobile/di/injection.dart'; import 'package:kmobile/di/injection.dart';
import 'package:flutter/material.dart';
import 'package:kmobile/api/services/cheque_service.dart';
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
class StopSingleChequeScreen extends StatefulWidget { class StopSingleChequeScreen extends StatefulWidget {
final User selectedAccount; final User selectedAccount;
@@ -180,19 +180,29 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
), ),
const SizedBox(height: 32), const SizedBox(height: 32),
ElevatedButton( ElevatedButton(
onPressed: () async { onPressed: () {
if (_formKey.currentState!.validate()) { if (_formKey.currentState!.validate()) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TransactionPinScreen(
onPinCompleted: (ctx, pin) async {
Navigator.pop(context);
try { try {
final response = await _chequeService.stopCheque( final response = await _chequeService.stopCheque(
accountno: widget.selectedAccount.accountNo!, accountno: widget.selectedAccount.accountNo!,
stopFromChequeNo: _stopFromChequeNoController.text, stopFromChequeNo:
_stopFromChequeNoController.text,
instrType: widget.instrType, instrType: widget.instrType,
stopToChequeNo: _stopFromChequeNoController.text, stopToChequeNo:
_stopFromChequeNoController.text,
stopIssueDate: _stopIssueDateController.text, stopIssueDate: _stopIssueDateController.text,
stopExpiryDate: _stopExpiryDateController.text, stopExpiryDate:
_stopExpiryDateController.text,
stopAmount: _stopAmountController.text, stopAmount: _stopAmountController.text,
stopComment: _stopCommentController.text, stopComment: _stopCommentController.text,
chequeIssueDate: widget.date, chequeIssueDate: widget.date,
tpin: pin,
); );
if (!mounted) return; if (!mounted) return;
final decodedResponse = jsonDecode(response); final decodedResponse = jsonDecode(response);
@@ -203,9 +213,29 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
} else { } else {
_showResponseDialog('Error', message); _showResponseDialog('Error', message);
} }
} catch (e) { } on Exception catch (e) {
_showResponseDialog('Error', e.toString()); print('inside catch block');
print(e.toString());
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: const Text('Stop Cheque'), child: const Text('Stop Cheque'),