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,11 +126,12 @@ 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,32 +210,62 @@ 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()) {
try { Navigator.push(
final response = await _chequeService.stopCheque( context,
accountno: widget.selectedAccount.accountNo!, MaterialPageRoute(
stopFromChequeNo: _stopFromChequeNoController.text, builder: (context) => TransactionPinScreen(
instrType: widget.instrType, onPinCompleted: (ctx, pin) async {
stopToChequeNo: _stopToChequeNoController.text, Navigator.pop(context);
stopIssueDate: _stopIssueDateController.text, try {
stopExpiryDate: _stopExpiryDateController.text, final response = await _chequeService.stopCheque(
stopAmount: _stopAmountController.text, accountno: widget.selectedAccount.accountNo!,
stopComment: _stopCommentController.text, stopFromChequeNo:
chequeIssueDate: widget.date, _stopFromChequeNoController.text,
); instrType: widget.instrType,
if (!mounted) return; stopToChequeNo:
final decodedResponse = jsonDecode(response); _stopToChequeNoController.text,
final status = decodedResponse['status']; stopIssueDate: _stopIssueDateController.text,
final message = decodedResponse['message']; stopExpiryDate:
if (status == 'SUCCESS') { _stopExpiryDateController.text,
_showResponseDialog('Success', message); stopAmount: _stopAmountController.text,
} else { stopComment: _stopCommentController.text,
_showResponseDialog('Error', message); chequeIssueDate: widget.date,
} tpin: pin,
} catch (e) { );
_showResponseDialog('Error', e.toString()); if (!mounted) return;
} final decodedResponse = jsonDecode(response);
final status = decodedResponse['status'];
final message = decodedResponse['message'];
if (status == 'SUCCESS') {
_showResponseDialog('Success', message);
} else {
_showResponseDialog('Error', message);
}
} on Exception catch (e) {
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,32 +180,62 @@ 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()) {
try { Navigator.push(
final response = await _chequeService.stopCheque( context,
accountno: widget.selectedAccount.accountNo!, MaterialPageRoute(
stopFromChequeNo: _stopFromChequeNoController.text, builder: (context) => TransactionPinScreen(
instrType: widget.instrType, onPinCompleted: (ctx, pin) async {
stopToChequeNo: _stopFromChequeNoController.text, Navigator.pop(context);
stopIssueDate: _stopIssueDateController.text, try {
stopExpiryDate: _stopExpiryDateController.text, final response = await _chequeService.stopCheque(
stopAmount: _stopAmountController.text, accountno: widget.selectedAccount.accountNo!,
stopComment: _stopCommentController.text, stopFromChequeNo:
chequeIssueDate: widget.date, _stopFromChequeNoController.text,
); instrType: widget.instrType,
if (!mounted) return; stopToChequeNo:
final decodedResponse = jsonDecode(response); _stopFromChequeNoController.text,
final status = decodedResponse['status']; stopIssueDate: _stopIssueDateController.text,
final message = decodedResponse['message']; stopExpiryDate:
if (status == 'SUCCESS') { _stopExpiryDateController.text,
_showResponseDialog('Success', message); stopAmount: _stopAmountController.text,
} else { stopComment: _stopCommentController.text,
_showResponseDialog('Error', message); chequeIssueDate: widget.date,
} tpin: pin,
} catch (e) { );
_showResponseDialog('Error', e.toString()); if (!mounted) return;
} final decodedResponse = jsonDecode(response);
final status = decodedResponse['status'];
final message = decodedResponse['message'];
if (status == 'SUCCESS') {
_showResponseDialog('Success', message);
} else {
_showResponseDialog('Error', message);
}
} on Exception catch (e) {
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'),