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';
class Cheque {
final String? type;
@@ -104,9 +106,16 @@ class ChequeService {
String? stopAmount,
String? stopComment,
String? chequeIssueDate,
required String tpin,
}) async {
final response = await _dio.post(
'/api/cheque/stop',
options: Options(
validateStatus: (int? status) => true,
receiveDataWhenStatusError: true,
),
data: {
'accountNumber': accountno,
'stopFromChequeNo': stopFromChequeNo,
@@ -117,11 +126,12 @@ class ChequeService {
'stopAmount': stopAmount,
'stopComment': stopComment,
'chqIssueDate': chequeIssueDate,
'tpin':tpin,
},
);
if (response.statusCode != 200) {
throw Exception("Error");
}
return response.toString();
if (response.statusCode != 200) {
throw Exception(jsonEncode(response.data));
}
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/data/models/user.dart';
import 'package:kmobile/di/injection.dart';
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
class StopMultipleChequesScreen extends StatefulWidget {
final User selectedAccount;
@@ -81,7 +82,7 @@ class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Stop Single Cheque'),
title: const Text('Stop Multiple Cheques'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
@@ -209,32 +210,62 @@ class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
),
const SizedBox(height: 32),
ElevatedButton(
onPressed: () async {
onPressed: () {
if (_formKey.currentState!.validate()) {
try {
final response = await _chequeService.stopCheque(
accountno: widget.selectedAccount.accountNo!,
stopFromChequeNo: _stopFromChequeNoController.text,
instrType: widget.instrType,
stopToChequeNo: _stopToChequeNoController.text,
stopIssueDate: _stopIssueDateController.text,
stopExpiryDate: _stopExpiryDateController.text,
stopAmount: _stopAmountController.text,
stopComment: _stopCommentController.text,
chequeIssueDate: widget.date,
);
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);
}
} catch (e) {
_showResponseDialog('Error', e.toString());
}
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TransactionPinScreen(
onPinCompleted: (ctx, pin) async {
Navigator.pop(context);
try {
final response = await _chequeService.stopCheque(
accountno: widget.selectedAccount.accountNo!,
stopFromChequeNo:
_stopFromChequeNoController.text,
instrType: widget.instrType,
stopToChequeNo:
_stopToChequeNoController.text,
stopIssueDate: _stopIssueDateController.text,
stopExpiryDate:
_stopExpiryDateController.text,
stopAmount: _stopAmountController.text,
stopComment: _stopCommentController.text,
chequeIssueDate: widget.date,
tpin: pin,
);
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'),

View File

@@ -1,9 +1,9 @@
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: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 {
final User selectedAccount;
@@ -180,32 +180,62 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
),
const SizedBox(height: 32),
ElevatedButton(
onPressed: () async {
onPressed: () {
if (_formKey.currentState!.validate()) {
try {
final response = await _chequeService.stopCheque(
accountno: widget.selectedAccount.accountNo!,
stopFromChequeNo: _stopFromChequeNoController.text,
instrType: widget.instrType,
stopToChequeNo: _stopFromChequeNoController.text,
stopIssueDate: _stopIssueDateController.text,
stopExpiryDate: _stopExpiryDateController.text,
stopAmount: _stopAmountController.text,
stopComment: _stopCommentController.text,
chequeIssueDate: widget.date,
);
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);
}
} catch (e) {
_showResponseDialog('Error', e.toString());
}
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TransactionPinScreen(
onPinCompleted: (ctx, pin) async {
Navigator.pop(context);
try {
final response = await _chequeService.stopCheque(
accountno: widget.selectedAccount.accountNo!,
stopFromChequeNo:
_stopFromChequeNoController.text,
instrType: widget.instrType,
stopToChequeNo:
_stopFromChequeNoController.text,
stopIssueDate: _stopIssueDateController.text,
stopExpiryDate:
_stopExpiryDateController.text,
stopAmount: _stopAmountController.text,
stopComment: _stopCommentController.text,
chequeIssueDate: widget.date,
tpin: pin,
);
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'),