From 6b4ad35217b5d9aed53472547a8d56ab1d231f7b Mon Sep 17 00:00:00 2001 From: faizatflutter Date: Thu, 21 May 2026 11:53:49 +0300 Subject: [PATCH] fixed er 'pickFiles' can't be acc --- assets/langs/ar-SA.json | 3 +- assets/langs/en-US.json | 3 +- lib/core/api/api_client.dart | 2 +- .../habib_wallet/habib_wallet_view_model.dart | 5 +- .../submit_refund_request_model.dart | 4 + .../refundable_invoices_response_model.dart | 3 + .../refund_request_view_model.dart | 6 +- lib/generated/locale_keys.g.dart | 1 + .../habib_wallet/habib_wallet_page.dart | 194 ++++++++++++++---- .../refund_request_create_page.dart | 7 +- pubspec.lock | 8 + pubspec.yaml | 2 + 12 files changed, 190 insertions(+), 48 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 12219c0c..fbd8465f 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -1892,5 +1892,6 @@ "requestNo": "رقم الطلب.", "referenceNo": "رقم المرجع", "advanceNumber": "رقم الدفعة المقدمة", - "amountOnly": "المبلغ" + "amountOnly": "المبلغ", + "invoiceHistory": "سجل الفواتير" } diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index d9ab9789..bfba9725 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -1885,7 +1885,8 @@ "referenceNo": "Reference No.", "refund": "Refund", "advanceNumber": "Advance Number", - "amountOnly": "Amount" + "amountOnly": "Amount", + "invoiceHistory": "Invoice History" } diff --git a/lib/core/api/api_client.dart b/lib/core/api/api_client.dart index d7717b54..f8919251 100644 --- a/lib/core/api/api_client.dart +++ b/lib/core/api/api_client.dart @@ -209,7 +209,7 @@ class ApiClientImp implements ApiClient { } // body['TokenID'] = "@dm!n"; - // body['PatientID'] = 4770714; + // body['PatientID'] = 4774167; // body['PatientID'] = 89754444; // body['PatientTypeID'] = 1; // body['PatientOutSA'] = 0; diff --git a/lib/features/habib_wallet/habib_wallet_view_model.dart b/lib/features/habib_wallet/habib_wallet_view_model.dart index e1e14ecf..00ba55cc 100644 --- a/lib/features/habib_wallet/habib_wallet_view_model.dart +++ b/lib/features/habib_wallet/habib_wallet_view_model.dart @@ -273,6 +273,8 @@ class HabibWalletViewModel extends ChangeNotifier { final request = SubmitRefundRequestModel( projectId: projectId, + isRefundFastTrack: true, + // in case of wallet refund, skip ITG approval refundType: '2', // wallet withdrawal refundProject: projectName, @@ -287,7 +289,8 @@ class HabibWalletViewModel extends ChangeNotifier { refundDoctorName: '', refundClinicId: 0, refundClinicName: '', - refundDestination: '2', // only bank transfer + refundDestination: '2', + // only bank transfer refundIban: iban, refundRemarks: remarks, refundTotalAmount: totalAdvancesBalance, diff --git a/lib/features/refund_request/models/req_models/submit_refund_request_model.dart b/lib/features/refund_request/models/req_models/submit_refund_request_model.dart index 3a8b104c..93eaadca 100644 --- a/lib/features/refund_request/models/req_models/submit_refund_request_model.dart +++ b/lib/features/refund_request/models/req_models/submit_refund_request_model.dart @@ -73,7 +73,9 @@ class SubmitRefundRequestModel { final String refundIban; final String refundRemarks; final double refundTotalAmount; + final bool isRefundFastTrack; final List refundProceduresList; + /// Populated only for wallet withdrawal refunds (refundType == '2'). final List refundAdvancesList; @@ -96,6 +98,7 @@ class SubmitRefundRequestModel { required this.refundIban, required this.refundRemarks, required this.refundTotalAmount, + required this.isRefundFastTrack, required this.refundProceduresList, this.refundAdvancesList = const [], }); @@ -118,6 +121,7 @@ class SubmitRefundRequestModel { "Refund_IBAN": refundIban, "Refund_Remarks": refundRemarks, "Refund_TotalRefundAmount": refundTotalAmount, + "Refund_IsFastTrack": isRefundFastTrack, }; if (refundType == '2') { diff --git a/lib/features/refund_request/models/resp_models/refundable_invoices_response_model.dart b/lib/features/refund_request/models/resp_models/refundable_invoices_response_model.dart index 2409f3ec..0178be6c 100644 --- a/lib/features/refund_request/models/resp_models/refundable_invoices_response_model.dart +++ b/lib/features/refund_request/models/resp_models/refundable_invoices_response_model.dart @@ -115,6 +115,7 @@ class RefundableInvoicesDetailsObject { final int? projectId; final List refundableInvoiceDetailsItems; final int? statusCode; + final bool? needITGApproval; RefundableInvoicesDetailsObject({ this.errorCode, @@ -123,6 +124,7 @@ class RefundableInvoicesDetailsObject { this.projectId, this.refundableInvoiceDetailsItems = const [], this.statusCode, + this.needITGApproval, }); factory RefundableInvoicesDetailsObject.fromJson(Map json) { @@ -137,6 +139,7 @@ class RefundableInvoicesDetailsObject { .toList() : [], statusCode: json['StatusCode'] as int?, + needITGApproval: json['NeedITGApproval'] as bool?, ); } } diff --git a/lib/features/refund_request/refund_request_view_model.dart b/lib/features/refund_request/refund_request_view_model.dart index 6c9b58dd..828e3d0a 100644 --- a/lib/features/refund_request/refund_request_view_model.dart +++ b/lib/features/refund_request/refund_request_view_model.dart @@ -108,6 +108,7 @@ class RefundRequestViewModel extends ChangeNotifier { void resetState() { currentStep = 0; procedures.clear(); + needITGApproval = false; selectedPaymentMethod = null; selectedRefundReason = null; isProceduresLoading = false; @@ -141,6 +142,7 @@ class RefundRequestViewModel extends ChangeNotifier { } } + void clearHospital() { selectedHospital = null; selectedInvoice = null; @@ -205,9 +207,11 @@ class RefundRequestViewModel extends ChangeNotifier { // ── Procedures ──────────────────────────────────────────────────────────── List procedures = []; bool isProceduresLoading = false; + bool needITGApproval = false; - void setProcedures(List list) { + void setProcedures(List list, {bool needsITGApproval = false}) { procedures = list; + needITGApproval = needsITGApproval; isProceduresLoading = false; notifyListeners(); } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 7700984d..07afd569 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -1879,4 +1879,5 @@ abstract class LocaleKeys { static const refund = 'refund'; static const advanceNumber = 'advanceNumber'; static const amountOnly = 'amountOnly'; + static const invoiceHistory = 'invoiceHistory'; } diff --git a/lib/presentation/habib_wallet/habib_wallet_page.dart b/lib/presentation/habib_wallet/habib_wallet_page.dart index db5990d1..4f056dad 100644 --- a/lib/presentation/habib_wallet/habib_wallet_page.dart +++ b/lib/presentation/habib_wallet/habib_wallet_page.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; import 'package:hmg_patient_app_new/core/app_assets.dart'; import 'package:hmg_patient_app_new/core/app_export.dart'; import 'package:hmg_patient_app_new/core/app_state.dart'; @@ -10,13 +11,19 @@ import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart'; +import 'package:hmg_patient_app_new/features/my_invoices/my_invoices_view_model.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/presentation/habib_wallet/recharge_wallet_page.dart'; import 'package:hmg_patient_app_new/presentation/habib_wallet/withdraw_request_create_page.dart'; +import 'package:hmg_patient_app_new/presentation/lab/lab_result_item_view.dart'; +import 'package:hmg_patient_app_new/presentation/my_invoices/widgets/invoice_list_card.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; +import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; +import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart'; import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart'; +import 'package:open_filex/open_filex.dart'; import 'package:provider/provider.dart'; class HabibWalletPage extends StatefulWidget { @@ -28,6 +35,7 @@ class HabibWalletPage extends StatefulWidget { class _HabibWalletState extends State { late HabibWalletViewModel habibWalletVM; + late MyInvoicesViewModel myInvoicesViewModel; @override void initState() { @@ -35,6 +43,8 @@ class _HabibWalletState extends State { habibWalletVM.initHabibWalletProvider(); habibWalletVM.getPatientBalanceAmount(); habibWalletVM.getLakumAccountInformation(); + myInvoicesViewModel.setInvoicesListLoading(); + myInvoicesViewModel.getAllInvoicesList(); }); super.initState(); @@ -43,6 +53,7 @@ class _HabibWalletState extends State { @override Widget build(BuildContext context) { habibWalletVM = Provider.of(context, listen: false); + myInvoicesViewModel = Provider.of(context, listen: false); AppState appState = getIt.get(); return Scaffold( backgroundColor: AppColors.bgScaffoldColor, @@ -144,45 +155,150 @@ class _HabibWalletState extends State { ), ], ), - SizedBox(height: 16.h), - Container( - decoration: RoundedRectangleBorder().toSmoothCornerDecoration( - color: AppColors.whiteColor, - borderRadius: 24.r, - hasShadow: false, - ), - child: Consumer(builder: (context, habibWalletVM, child) { - return ListView.separated( - itemCount: habibWalletVM.habibWalletBalanceList.length, - physics: NeverScrollableScrollPhysics(), - padding: EdgeInsets.only(top: 8, bottom: 8), - shrinkWrap: true, - itemBuilder: (context, index) { - return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: habibWalletVM.habibWalletBalanceList[index].projectDescription! - .toText16(isBold: true, color: AppColors.textColor)), - Utils.getPaymentAmountWithSymbol2( - habibWalletVM.habibWalletBalanceList[index].patientAdvanceBalanceAmount!, //did the changes because of negative value - textColor: AppColors.textColor, - iconColor: AppColors.textColor, - iconSize: 18.h, - isExpanded: false, - fontSize: 28.f, - fontWeight: FontWeight.w600, - letterSpacing: -1), - ], - ).paddingSymmetrical(0, 12.h); - }, - separatorBuilder: (BuildContext context, int index) { - return Divider(height: 1, color: AppColors.textColor.withAlpha(20)); - }, - ).paddingSymmetrical(16.h, 24.h).toShimmer2(isShow: habibWalletVM.isWalletAmountLoading); - }), - ), SizedBox(height: 24.h), + // Container( + // decoration: RoundedRectangleBorder().toSmoothCornerDecoration( + // color: AppColors.whiteColor, + // borderRadius: 24.r, + // hasShadow: false, + // ), + // child: Consumer(builder: (context, habibWalletVM, child) { + // return ListView.separated( + // itemCount: habibWalletVM.habibWalletBalanceList.length, + // physics: NeverScrollableScrollPhysics(), + // padding: EdgeInsets.only(top: 8, bottom: 8), + // shrinkWrap: true, + // itemBuilder: (context, index) { + // return Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Expanded( + // child: habibWalletVM.habibWalletBalanceList[index].projectDescription! + // .toText16(isBold: true, color: AppColors.textColor)), + // Utils.getPaymentAmountWithSymbol2( + // habibWalletVM.habibWalletBalanceList[index].patientAdvanceBalanceAmount!, //did the changes because of negative value + // textColor: AppColors.textColor, + // iconColor: AppColors.textColor, + // iconSize: 18.h, + // isExpanded: false, + // fontSize: 28.f, + // fontWeight: FontWeight.w600, + // letterSpacing: -1), + // ], + // ).paddingSymmetrical(0, 12.h); + // }, + // separatorBuilder: (BuildContext context, int index) { + // return Divider(height: 1, color: AppColors.textColor.withAlpha(20)); + // }, + // ).paddingSymmetrical(16.h, 24.h).toShimmer2(isShow: habibWalletVM.isWalletAmountLoading); + // }), + // ), + // SizedBox(height: 16.h), + // Invoices Section + Consumer(builder: (context, myInvoicesVM, child) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.invoiceHistory.tr(context: context).toText18(isBold: true, color: context.textColor), + SizedBox(height: 12.h), + ListView.builder( + itemCount: myInvoicesVM.isInvoicesListLoading + ? 4 + : myInvoicesVM.allInvoicesList.isEmpty + ? 1 + : myInvoicesVM.allInvoicesList.length, + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsetsGeometry.zero, + itemBuilder: (context, index) { + return myInvoicesVM.isInvoicesListLoading + ? LabResultItemView(onTap: () {}, labOrder: null, index: index, isLoading: true) + : myInvoicesVM.allInvoicesList.isNotEmpty + ? AnimationConfiguration.staggeredList( + position: index, + duration: const Duration(milliseconds: 500), + child: SlideAnimation( + verticalOffset: 100.0, + child: FadeInAnimation( + child: AnimatedContainer( + duration: Duration(milliseconds: 300), + curve: Curves.easeInOut, + child: InvoiceListCard( + getInvoicesListResponseModel: myInvoicesVM.allInvoicesList[index], + onTap: () async { + if (Utils.isVidaPlusProject(myInvoicesVM.allInvoicesList[index].projectId ?? 0)) { + LoaderBottomSheet.showLoader(loadingText: LocaleKeys.sendingEmailPleaseWait.tr(context: context)); + await myInvoicesViewModel.sendInvoiceEmail( + appointmentNo: myInvoicesVM.allInvoicesList[index].appointmentNo!, + projectID: myInvoicesVM.allInvoicesList[index].projectId!, + onSuccess: (val) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight(context, + child: Utils.getSuccessWidget( + loadingText: LocaleKeys.emailSentSuccessfullyMessage.tr(context: context)), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + isAutoDismiss: true); + }, + onError: (err) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight( + context, + child: Utils.getErrorWidget(loadingText: err), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + }); + } else { + LoaderBottomSheet.showLoader(loadingText: LocaleKeys.loadingText.tr(context: context)); + myInvoicesViewModel.downloadInvoicePDF( + setupId: myInvoicesVM.allInvoicesList[index].setupId!, + invoiceNo: myInvoicesVM.allInvoicesList[index].invoiceNo!, + projectID: myInvoicesVM.allInvoicesList[index].projectId!, + onError: (err) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight( + context, + child: Utils.getErrorWidget(loadingText: err), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + }, + onSuccess: (value) async { + LoaderBottomSheet.hideLoader(); + if (myInvoicesViewModel.downloadInvoicePDFBase64!.isNotEmpty) { + String path = + await Utils.createFileFromString(myInvoicesViewModel.downloadInvoicePDFBase64!, "pdf"); + try { + OpenFilex.open(path); + } catch (ex) { + showCommonBottomSheetWithoutHeight( + context, + child: Utils.getErrorWidget(loadingText: LocaleKeys.cannotOpenThisFile.tr()), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + } + } + }, + ); + } + }, + ), + ), + ), + ), + ) + : Utils.getNoDataWidget(context); + }, + ), + ], + ); + }), ], ), ), @@ -191,3 +307,5 @@ class _HabibWalletState extends State { ); } } + + diff --git a/lib/presentation/refund_request/refund_request_create_page.dart b/lib/presentation/refund_request/refund_request_create_page.dart index fd64bb67..1d0f723f 100644 --- a/lib/presentation/refund_request/refund_request_create_page.dart +++ b/lib/presentation/refund_request/refund_request_create_page.dart @@ -9,7 +9,6 @@ import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/extensions/route_extensions.dart'; import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; -import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart'; import 'package:hmg_patient_app_new/features/my_invoices/models/get_invoices_list_response_model.dart'; import 'package:hmg_patient_app_new/features/refund_request/models/req_models/submit_refund_request_model.dart'; import 'package:hmg_patient_app_new/features/refund_request/refund_request_view_model.dart'; @@ -46,7 +45,6 @@ class RefundRequestCreatePage extends StatefulWidget { class _RefundRequestCreatePageState extends State { late RefundRequestViewModel _refundRequestViewModel; - late HabibWalletViewModel _habibWalletViewModel; late AppState _appState; final TextEditingController _ibanController = TextEditingController(); @@ -94,7 +92,7 @@ class _RefundRequestCreatePageState extends State { apiProcedureId: item.procedureId, )) .toList(); - _refundRequestViewModel.setProcedures(procedures); + _refundRequestViewModel.setProcedures(procedures, needsITGApproval: details.needITGApproval ?? false); }, ); } @@ -534,7 +532,7 @@ class _RefundRequestCreatePageState extends State { final request = SubmitRefundRequestModel( projectId: invoice.projectId ?? 0, refundType: '1', - // 1 = invoice refund + isRefundFastTrack: vm.needITGApproval, refundProject: invoice.projectName ?? '', refundProjectId: invoice.projectId ?? 0, refundPatientId: patientId.toString(), @@ -643,7 +641,6 @@ class _RefundRequestCreatePageState extends State { @override Widget build(BuildContext context) { - _habibWalletViewModel = context.read(); return Consumer( builder: (context, vm, _) { return Scaffold( diff --git a/pubspec.lock b/pubspec.lock index ce36792b..e76aec05 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -688,6 +688,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.6.1" + flutter_paytabs_bridge: + dependency: "direct main" + description: + name: flutter_paytabs_bridge + sha256: fc48e68848147a8edf41b27f9068b988c4fb28ff9778bf20560a90be0b4dddfb + url: "https://pub.dev" + source: hosted + version: "2.7.13" flutter_plugin_android_lifecycle: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 3d087f6f..33cbdf4b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -175,3 +175,5 @@ flutter: - asset: assets/fonts/gess_two/GE_SS_Two_Light.otf weight: 400 + +